- Michael Barton |
- Apache, Tips |
- October 13th, 2010
One thing that I constantly have to do with sites is add, for SEO purposes, a redirect of non-www to www. The reason being, Google sees michaelbarton.name and www.michaelbarton.name as two different sites and I’d get penalized for having duplicate content should someone out there link to my site using one or the other.
The solution being, choose which one you want to have redirect – non-www to www or www to non-www. The choice is yours. It’s really just a personal preference for me to use www in front of my domain.
The Solution: non-www to www
1 2 3 4 5 6 | <ifmodule mod_rewrite.c> RewriteEngine On # Redirect non-www to www RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </ifmodule> |
