Remove/Force www on Your Domain and 301 Redirect

You want to ensure that Google and other SEs only see one domain so you don’t penalized for duplicate content (www and non-www indexed pages are not the same and counted as duplicates).

.htaccess

To redirect to domain.com and 301 existing pages:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]

To redirect to www.domain.com and 301 existing pages:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

Google

If you a Google Webmaster account you can also make sure that the preferred domain matches your domain redirection choice.

  1. Log on to Google Webmaster Tools
  2. Click Settings
  3. In the Preferred Domain section make your selection and click Save


Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter

Related Posts

Tags: , ,

Leave a Reply





Donate

If you found this article useful and would like to see more like it this please consider making a donation.