View Single Post
Old 10-22-2012, 11:58 PM   PM User | #1
MBI
New to the CF scene

 
Join Date: Oct 2012
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
MBI is an unknown quantity at this point
Help with adding trailing slash to URL (.htaccess)

So I have been able to hide the .html extension on my pages, but I can't seem to get the trailing slash working. I've tried multiple codes with no luck. Here is how I configured my .html extension removal in .htaccess:

#force www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

# remove .html ONLY if requested directly
RewriteCond %{THE_REQUEST} (\.html\sHTTP/1)
RewriteRule ^(.+)\.html$ /$1 [R=301,L,QSA]

# remove trailing slash ONLY if it is not an existing folder
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# rewrite to FILENAME.html if such file does exist and is not a folder
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /$1.html [L,QSA]
MBI is offline   Reply With Quote