Hi, I need help about server wide configuration. I write this post to be as complete as possible as to be a reference to people looking for similar solution.
Myself: Been searching for many months this solution, 100+ hours.
Situation: I have a dedicated server but not for resell, it is for my webmasters to manage my websites.
I wish to have server wide configuration and then prohibit the use of .htaccess to my webmasters. For security purpose, but mostly for performance.
It is recommended by apache documentation to use httpd.conf over .htaccess for performance issue and this is what I want.
I do it through the include editor in apache configuration so that my modifications are kept when there is an update of version. This is the official way recommended. But few seems to do it this way.
In the "Pre VirtualHost Include" I have inserted my .htaccess and appart from including the Directory, the syntax is the same.
Now, I want my .htaccess for a website to be generic and apply theses rules to every websites on the server.
First, Is it sane to do this?
Second, I managed to do it server wide for not using www this way:
<Directory /home/*/public_html>
RewriteEngine On
Options -Indexes +FollowSymLinks
# redirect www to no-www
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule .? [
%1%{REQUEST_URI}...] [R=301,L]
</Directory>
I have not seen this anywhere on the web yet.
All my websites and sub-domains and now free of www.
Now I wish to have extensionless also server wide.
here is the code I use successfully for a domain:
###Remove File Extension From URL - BEGIN
IndexOptions FancyIndexing
Options All
# Externally redirect client requests contains htm/html extension to
# extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*[^.]+\.html?
# Externally redirect to extensionless URI
RewriteRule ^(([^/]+/)*[^.]+)\.html?$ [
yourwebsite.com...] [R=301,L]
# If requested extensionless URL-path does not resolve to an existing directory
RewriteCond %{REQUEST_FILENAME} !-d
# If requested extensionless URL-path plus ".html" does resolve to an existing file
RewriteCond %{REQUEST_FILENAME}.html -f
# then append ".html" to resolve the actual filename
RewriteRule ^(([^/]+/)*[^./]+)$ /$1.html [L]
###Remove File Extension From URL - END
How can I make this server wide without adding a website adress but a generic rule for all domains?
Then I would add:
# Prohibit the use of .htaccess
AllowOverride None
I think this would be the best performance/security solution but I need help & advise because it is too much for me alone. I have been searching all over but could not find infos about this situation. Thank you so much for your help!