mod_rewrite to force www redirect index.php to domain

Here is a quick mod_rewrite example that forces www and redirects index.php to / (this fixes two canonicalization issues at one time).

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.site.com$
RewriteRule ^/(.*)$ http://www.site.com/$1 [R=301]
RewriteRule ^/index\.php$ http://www.site.com/ [R=301,L]

You Might Also Like...

blog comments powered by Disqus