So let us say that my website is www.example.com and I have a contact.html page in the root. The URL normally shown in the address bar is: http://example.com/contact.html
For my site, I want the URL to have:
- no www
- no .html
- a trailing slash
So the final result should look like this: http://example.com/contact/
Condition No. 1 is default, so that doesn't bother me.
For Condition 2 (no '.html'), I have the following code into my .htaccess file place in the root directory:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
...and it works perfectly.
Now coming on to Condition 3 (enforcing trailing slash), I have the following code into the .htaccess file before the 'Condition 2' rewrite commands:
RewriteEngine On
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
...this does not work; The page redirects to the Error 404 page and the address bar shows: http:/example.com/404.html... YES, with the trailing slash :/
What am I doing wrong?
I have a folder called archives in the root directory of which I want indexing to be done. So I simply added a .htaccess file in the 'archives' folder and added the following, simple code:
Options +Indexing
But it doesn't work; I get redirected to the Error 403 page! I'm 99% sure that it is due the .htaccess file in the root directory.