Automatically redirect non-www requests to www for all URLs and All Domains

Redirecting non-www to www for ALL of your domains.

This guide will quickly go over why you should not use both www and non www versions of your domain, but choose only one, and how this affects your search engine rankings for Google.

Why you should only have www or non www, but not both for your website and it’s search engine optimization.

Many people have made their website accessible both through http://www.domain.com as well as just http://domain.com. This is not generally a good idea for your SEO (search engine optimization). You’re asking “Why?”, and I will explain. Google “king of search engines” and the only search engine that really should be important to you, treats subdomains as separate domains than the main domain.

In Google’s eyes; www.domain.com, domain.com are separate websites. If you are thinking “Great! My website is then going to be listed twice at Google!”, you will now need to reconsider, being wiser.

Google looks for “duplicate content”, or content which appears in more than one location. If you have the same blog entry written twice, in different locations on your website, you will lose some ranking for this. If you have copied text from another website, Google will try and determine which site first appeared with that original content, and will rank the rest a bit lower.

So what’s the point of all this www and non www talk?

If Google treats www.domain.com and domain.com as separate sites, and each one actually displays the same identical content, Google will rank both domain and www. subdomain lower, due to duplicate content.

How we do it where I’m from…

If you want to have all your URLs have a “www” in front of them then paste the following code inside of your “.htaccess” file.
If you don’t have a .htaccess file, create a new text document, paste in the below code, and upload it to the directory on your web host just above all of your domain name’s folders. Once uploaded, rename it to be “.htaccess”.

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI}\\/%{HTTP_HOST}/www. ^/+(.+/)?[^.]*[^/]\\(/)([^w][^w][^w][^.].*/(www\.)¦.*)$ [OR,NC]
RewriteCond %{HTTP_HOST}/www. ^(/)?(/)?([^w][^w][^w][^.].*/(www\.))$ [NC]
RewriteRule ^ http://%4%{HTTP_HOST}%{REQUEST_URI}%2 [L,R=301]

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

3 Responses



Leave a Reply

*