So, it's been ages since I have needed to plunge the depths of .htaccess, but I am in need of advice again now.
After lots of messing about the only combination of rules I can get to work properly are as follows:
[code]
# Redirect 404 Error
ErrorDocument 404 /404.html
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$
http://evokeartdesign.com/ [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.(evokeartdesign\.com)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#Add a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.+)$ /$1/ [L,R=301]
# Remove file extensions
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+)/$ /$1.html [QSA,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+)/$ /$1.php [QSA,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.php$ /$1 [R=301,L]
[/code]
However, I now have two issues that need resolving:
1. I need to allow a specific IP address to view all of the original file extensions online. This is due to CMS requirements which need to interact with original files, not truncated ones. I have been told this needs to go somewhere in the code (IP address in replacement of #):
[code]RewriteCond %{REMOTE_ADDR} ^###\.###\.###\.###[/code]
This would exclude this IP from the rules, i.e. allowing it to view them as normal. I'm not sure how to structure the code so that this will work, or if there is a catch-all statement which will do this for all the above.
2. The .htaccess code above as it is structured doesn't seem to allow for the 404 error to come into play. For instance if I type
http://evokeartdesign.com/pagenotfound.html the only thing that happens is a trailing slash is added ... have you any ideas why the 404 error would not work in this instance?
Thanks in advance!