Hi, How do I redirect: http://domain.com/ http://domain.com/index.php http://www.domain.com/index.php all to http://www.domain.com/ At the moment I am using the below, but it does not redirect http://domain.com/index.php RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
To redirect index.php, try this: RewriteCond %{HTTP_HOST} ^domain.com$ [OR] RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteRule ^index\.php$ "http\:\/\/www\.domain\.com" [R=301,L]
Hmm that seems to redirect: http://domain.com/index.php and http://www.domain.com/index.php but not http://domain.com/
So is it not possible to do that and also redirect domain.com to www.domain.com? I tried adding a simple: redirect 301 /index.php http://www.domain.com.au/ But it caused an error/loop or something and the page failed to load.
RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] Is what is in there right now. That deals with domain.com to www.domain.com just fine, but does not deal with index.php The one you posted works awesome to redirect index.php but does not do what the above does.
You must combine both yours and my code together. RewriteEngine on RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] RewriteCond %{HTTP_HOST} ^domain.com$ [OR] RewriteCond %{HTTP_HOST} ^www.domain.com$ RewriteRule ^index\.php$ "http\:\/\/www\.domain\.com" [R=301,L]