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]
If you a Google Webmaster account you can also make sure that the preferred domain matches your domain redirection choice.
- Log on to Google Webmaster Tools
- Click Settings
- In the Preferred Domain section make your selection and click Save
Related Posts
Tags: 301 redirect, htaccess, remove www





















