Techblog Index

Quick Tip: Forcing www. to avoid duplicate content

Google (and other search engines) treats subdomains as different websites so if you are linked / accessed both via http://www.yourdomain.com and http://yourdomain.com you may get your content classified as duplicate since will be the same on both.

To avoid this simply add a rule to a .htaccess file in your root directory:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L]
</IfModule>

NOTE: You need to have mod_rewrite enabled in your server in order to do this.

 
 

Reader's thoughts on "Quick Tip: Forcing www. to avoid duplicate content"

1
  1. Cool, I think I can do that.

Leave a Reply