0

At .htaccess I have such a rule to redirect from site.com to www.site.com:

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

It works fine, but also I need to redirect from site.com/index.html to http://www.site.com I have add this one:

RewriteCond %{HTTP_HOST} ^site.com/index.html$
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]

But it doesn't work :( Anybody help please?

0

2 Answers 2

0

Do this:

RewriteEngine on

RewriteRule ^index.html$ / [R=301,L]

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

Do not forget to clear your browser's cache! Before trying the above.

1
  • RewriteCond %{HTTP_HOST} ^site.com$ RewriteRule ^(.*)$ site.com/$1 [L,R=301] This working but not this - RewriteRule ^index.html$ / [R=301,L] - I have clear my browser's cache ofcourse.
    – John Smith
    Feb 29, 2012 at 15:57
0

try putting your second condition before the first one and it should work.

EDIT:

try this as your first rule:

RewriteRule ^site.com/index.html$ http://www.site.com [L,R=301]

(i guess your your 2nd rule is wrong._

1
  • If your suggestion does not work I all the same need to accept it?
    – John Smith
    Feb 29, 2012 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.