Forum Moderators: phranque

Message Too Old, No Replies

301 redirect domain.com/index.php to domain.com

301 redirect domain.com/index.php to domain.com

         

digitalpimp

8:56 am on Mar 7, 2008 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ [domain.com...] [R=301,L]

Ivetried the above and it works fine redirecting index.php but some urls end in /index.php?someotherstuffhere which also redirect to domain.com/ so the pages never load

Can someone tell me how to change it so its only index.php exactly gets redirected and those other pages work as normal

jdMorgan

3:08 pm on Mar 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Change the RewriteCond pattern so that it matches only if there is no query string following index.php:

RewriteCond %{THE_REQUEST} ^([^/]+/)*index\.php\ HTTP/
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(([^/]+/)*)index.php$ http://www.domain.com/$1 [R=301,L]

Other tweaks to improve pattern-matching speed.

Jim