301 redirect non www to www but preserve previous rule which removes index.php |
[eluser]megamonk[/eluser]
i currently have this in my htaccess Code: RewriteEngine on this basically strips out the index.php now i need to redirect all non www to www url so i tried adding this Code: RewriteCond %{HTTP_HOST} ^mysite.com$ [NC] it works fine except that the index.php is added after the url whenever a non www url is typed. ex: mysite.com = http://www.mysite.com mysite.com/about = http://www.mysite.com/index.php/about i want to remove that "index.php". any ideas?
[eluser]Daniel Moore[/eluser]
Make sure you redirect to the "www." part first, then process the removal of the index.php afterward. Code: RewriteEngine On Don't put an L next to R=301 when forcing a redirect to "www.", or no more rules will be processed. Also, add the R=301 to the removal of the index.php, so that search engines will remember not to try the index.php next time.
[eluser]tison[/eluser]
Guys, This is the final code I used - this not only redirects index.php, but also redirects non-www requests to www. (if you're using non-www, simply remove the middle rules): Code: RewriteEngine On |
Welcome Guest, Not a member yet? Register Sign In |