Forum Moderators: phranque
RewriteRule ^index.php$ http://www.domain.com/ [R=301,L] There are some pages which have the index.php in the url followed by some other directives and my code removes the index.php from those and breaks them. All i want to do is redirect the one instance of [domain.com...] to the root with no other affect on any other url.
This htaccess newb will be very obliged if any of you can help!
Let me know if you want the full htaccess file.
What "other directives" specifically?
If you are referring to a query string attached to the URL, then adding
RewriteCond %{QUERY_STRING} =""
However, if you've got index.php defined as your DirectoryIndex (using that directive), then the rule will need further qualification to avoid creating an 'infinite' rewrite/redirect loop. In that case, you'd need to examine THE_REQUEST to be sure that only direct client requests for index.php will be redirected, and that requests for index.php occurring as a result of DirectoryIndex rewriting requests for "/" to "/index.php" won't be redirected.
Luckily, the RewriteCond to do this can replace the one added above, so the code isn't much longer:
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php\ HTTP/
RewriteRule ^index.php$ http://www.example.com/ [R=301,L]
GET /index.php HTTP/1.1
GET /index.php?sid=123 HTTP/1.1
Jim
Jim