Craig McCoy

Programmer / Developer & Zombie Survivalist

SEO

mod_rewrite to force www redirect index.php to domain

Feb/2010 28

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]

Pages

Subscribe to RSS - SEO