I’ve trawled through Google for days on end now trying to find a solution to my problem, patching in segments of code to no avail. Nothing has worked. I just want to remove the file extension .shtml from my URL but NOTHING works. I’ve made sure the file is being updated and my website isn’t being loading from cache and all that malarcky. Can someone tell me where I’m going wrong, please?
Only thing I can think of is that my web hosting (Hostgator) doesn’t have the Apache mod_rewrite enabled?
RewriteEngine On
#Remove file extensions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.shtml -f
RewriteRule ^(([^/]+/)*[^.]+)$ /$1.shtml [L]
#Add trailing slash
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !#
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mythofechelon.co.uk/$1/ [L,R=301]
Help would be much appreciated.
In place of your extension removing code have this code instead:
Adding Trailing Slash
However keep in mind that even a URI of
http://domain.com/foo#aaawill becomehttp://domain.com/foo/#aaabecause there is no way to detect#from mod_rewrite since that is handled entirely by browsers.