Redirect /index.php to / with WordPress
When evaluting the search engine rankings for some clients with WordPress blogs I noticed that many of the engines were indexing the http://www.domain.com/index.php and http://www.domain.com/ URLs separately. Obviously this is not ideal as it splits up the ranking and authority for that single page into two unique URLs. Having WordPress in the mix complicates the solution because it already adds mod_rewrite rules to the .htaccess file to handle the permalinks for your blog. Here’s the trick to make it work:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteRule . / [R=301,L]
Add the above rules before the WordPress mod_rewrite rules. The trick here is that the rule matches the actual URL specified in the HTTP request. If you try using a rule that matches REQUEST_URI (or similar) you’ll get an infinitely looping redirect because it conflicts with the WordPress rules.
Hey this was a big help. Thanks
dax
Ryan, thanks a lot. I didn’t even think of that before. Thanks for the easy fix!
Thank you for the help. That worked with my site.