Forum Moderators: phranque

Message Too Old, No Replies

Redirect index.html to root

         

neelkumar

1:36 pm on Jul 15, 2006 (gmt 0)

10+ Year Member



Hi

I wish to permanent redirect the [mydomain.com...] page to [mydomain.com...] root.

I am using following in the .htaccess

Redirect 301 /index.html [mydomain.com...]

but it goes into a loop. Can you please point out what is wrong and what could be the exact command or rule.

bobothecat

2:07 pm on Jul 15, 2006 (gmt 0)



You could try:

RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]\

neelkumar

2:14 pm on Jul 15, 2006 (gmt 0)

10+ Year Member



My .htaccess file already has these lines

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

to redirect non www to www.

Now I have added this line

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]

But it still goes in a loop.

bobothecat

9:07 pm on Jul 15, 2006 (gmt 0)



Here's what I have, and it works fine:

RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . http://www.example.com%1/%2 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]\

Perhaps Jim could chime in if you continue to have problems.

Peter