Forum Moderators: phranque
RewriteRule ^(.*)index\.(php|htm?)$ /$1 [R=301,NC,L] RewriteCond %{THE_REQUEST} ^.*/index.htm
RewriteRule ^(.*)index.htm$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)/directory/index.php$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/((?:\w+/)*)index\.php
RewriteRule index\.php$ http://example.com/%1 [R=301,NS,L]
RewriteCond %{REQUEST_URI} ^((\w+/)*)index\.(php|htm)
RewriteRule index\.(php|htm) http://www.example.com/%1 [R=301,L,NS]
DirectoryIndex index.htm index.php
listing them in order of overall frequency. The server will look for one after another, stopping as soon as it finds one.
RewriteCond %{THE_REQUEST} ^.*/index.htm
RewriteRule ^(.*)index.htm$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)/directory/index.php$ http://www.example.com/$1 [R=301,L]
www.example.com/folder/index.php redirects to www.example.com/folder/index/
However, I want it to redirect to www.example.com/folder/
RewriteCond %{REQUEST_URI} !index\.php
or, wait, you don't need that, just add a [NS] flag to your php redirect.