An SEO conscious customer was having duplicate content issues for:

http://domain.com/something/

and

http://domain.com/something/index.php

Simply rewriting index.php to / will not be effective as httpd makes an internal redirect to the DirectoryIndex, causing a redirect loop.

In order to distinguish between the internal redirect and a client request, the %{THE_REQUEST} server variable is used.

When placed in the in the Directory context in the httpd.conf or in the .htaccess file located in the document root or desired origin directory, the following rule will achieve the desired results:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]+\ (.*)/index.php\ HTTP/
RewriteRule .*index.php$ http://%{HTTP_HOST}%1/ [L]

Note, this should be placed before any query_string rewriting you are doing for things like clean urls.

This will work recursively from its origin, so:

http://domain.com/something/index.php

and

http://domain.com/something/else/index.php

will be rewritten to:

http://domain.com/something/

and

http://domain.com/something/else/