Forum Moderators: phranque
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
And it works like this:
1. example.com
2. example.com/index.html
3. example.com/forum/
4. example.com/forum/index.html
5. forum.example.com
6. forum.example.com/index.html
7. forum.example.com/test/
8. forum.example.com/test/index.html
->
1. www.example.com
2. www.example.com
3. www.example.com/forum/
4. www.example.com/forum/
5. forum.example.com
6. www.example.com/forum/ ( >>WRONG<< )
7. forum.example.com/test/
8. www.example.com/forum/test/ ( >>WRONG<< )
So as you can see the index.html to "/" doesn't work on subdomains.
Can anyone please help me with this?
[edited by: jdMorgan at 4:34 am (utc) on July 17, 2009]
[edit reason] example.com [/edit]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/#?\ ]+/)*index\.html?\ HTTP/
RewriteCond %{HTTP_HOST} ^((www¦forum)\.example\.com) [OR]
RewriteCond www.%{HTTP_HOST} ^(www\.example\.com)
RewriteRule ^(([^/]+/)*)index\.html?$ http://%1/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
Replace the broken pipe "¦" character above with a solid pipe character before use; Posting on this forum modifies the pipe characters.
Jim
Rule execution order is critical, since you do not want your internally-rewritten filepaths exposed to the client as URLs by subsequent external redirects.
To avoid this and other unexpected effects, place all external redirects first, in order from most-specific patterns and conditions (fewest URLs affected) to least-specific (most URLs affected), followed by all internal rewrites, again in order from most-specific to least-specific patterns/conditions.
Jim
That mechanism and the redirects above are interfering with each other, and the cause of this interference must be found and fixed.
Our forum Charter contains links to resources about .htaccess and mod_rewrite -- See links at top of this page).
Jim