Hi guys, I have just switched hosts and my new host does not automatically redirect flat links. example - http://www.absale.com/page gives 404 error instead of going to page.html I have added this code to the .htaccess RewriteRule ^(.+)$ http://www.absale.com/$1.html [R=301,NC] Unfortunately that produces an endless string .html.html.html.html What have I overlooked?
(.+) will capture any character, once or more times. It will therefore, create an infinite loop as you've suggested. You should use a different rule, i.e. to only capture URL's that don't contain a full stop. Jay
Thanks for your help jayshah. For anybody else who has the same problem in future, I found the answer here - http://www.easymodrewrite.com/example-extensions
From the advanced .htaccess tutorial. This code will only perform the redirect if the request is not a directory, and if the request.html exists. Much better/safer. Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^([^\.]+)$ http://www.absale.com/$1.html [R=301,NC] Code (markup):