Forum Moderators: phranque
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]
If the user typed any of the following
http://www.example.com/index.php
http://www.example.com/dir/index.php
http://www.example.com/dir2/index.php
http://www.example.com/dir1/abc/index.php
# Fix only index files to "/", and force www for those at the same time.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.(html?¦php¦asp¦cfm)\ HTTP/
RewriteRule ^(.*)index\.(html?¦php¦asp¦cfm)$ http://www.domain.com/$1 [R=301,L]
# Force www for all other non-index URLs.
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]