Forum Moderators: phranque
I was a little confused after reading this discussion [webmasterworld.com], as the recommended version of the .htaccess went through several variations by the time the thread ended. So just to confirm, is the code below the correct format to use?
Thanks...
====================
RewriteEngine on
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.html?
RewriteRule ^(([^/]*/)*)index\.html?$ http://example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule (.*) http://example.com/$1 [R=301,L]
====================
......................
This is why mod_rewrite is called "voodoo." It is a tiny 'procedural language' used with regular-expressions, another tiny character-matching language. But the combinaton of these two results in a rather awesome number of application possibilities. While it can be proven that the number of possible incorrect possibilities is extremely large, the number of correct possibilities is also very large. But that's for math majors...
The only way to know if your code is "correct" for your application is to test it thoroughly. You can use the Live HTTP Headers extension for Mozilla browsers to confirm a proper 301 HTTP response in each case, observe the browser address bar as redirects occur, and check whether the results are what you desire. That's the only way to know if it's correct for you.
Jim