Forum Moderators: phranque
My homepage is located at "/document/home". However, I want to be able to rewrite it as "/", i.e. root. Further, I want all requests for "/document/home" to 301 redirect to "/". The snippet from my .htaccess file is as follows, but I get stuck in an endless loop:
----------------------------------
RewriteRule ^document/home/$ / [R=301]
RewriteRule ^document/home/$ / [R=301]
RewriteRule ^$ /document/home/ [L]
# Externally redirect only original client requests for /document/home with optional trailing slash
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /document/home/?\ /HTTP/
RewriteRule ^document/home/?$ http://www.example.com/ [R=301,L]
# Internally rewrite requests for document_root "/" to /document/home/
RewriteRule ^$ /document/home/ [L]
GET /document/home HTTP/1.1
This variable is not affected by any internal rewrites, and so can be used to prevent the loop.
Jim
That seems very logical, but unfortunately it doesn't work.
I put the lines in my .htaccess file as follows:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /document/home/?\ HTTP/
RewriteRule ^document/home/?$ http://www.example.com/ [R=301,L]
RewriteRule ^$ /document/home/ [L]
It correctly rewrites / to /document/home. But doesn't redirect /document/home/ to /
Thanks for your help!
[edited by: jdMorgan at 1:44 am (utc) on Dec. 23, 2005]
[edit reason] Corrected per msg#4 [/edit]