Solving Canonical Problems with WWW

By jebernierSearch Engine Optimization (SEO), Comments are off

One of the most common problems in websites is the same content being available at both the WWW and non-WWW versions of a domain. 

Having the same content available on both the WWW and non-WWW versions of a domain (such as and is called canonicalization. While you and I might realize they are in fact the same page, search engines mistake them to be unique pages.

Most of the time, search engines can figure out that they are the same page and only include the canonical URL in their index. SEObook explains the canonical URL as:

"The canonical version of any URL is the single most authoritative version indexed by major search engines. Search engines typically use PageRank or a similar measure to determine which version of a URL is the canonical URL."

Regardless, canonicalization can result in indexing problems and duplicate content issues. Most importantly, canonicalization will split the link juice between each version as people link to and share both.

What you want to see is a redirection from the WWW to the non-WWW, or vice versa, so that if the wrong version is entered or linked to, the user is automatically taken to the canonical URL. Fortunately, this is relatively easy to set up.

Google Webmaster Tools:

If you’ve verified your site with Google Webmaster Tools, you can set your preferred domain by going to Site Configuration > Settings, and selecting either ‘Display URLs as’ or ‘Display URLs as’.

This will make sure that Google only indexes your preferred canonical URL. However, it doesn’t fix the problem of splitting your link juice so you should still set up a redirect using the following method:

Redirect Using .htaccess

If your site is hosted on Apache, you can redirect from the WWW to the non-WWW, or vice versa, with a few lines in your .htaccess file.

Redirect WWW to non-WWW:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(yourdomain\.com)?$
RewriteRule ^(.*)$$1 [R=301,L]

Redirect non-WWW to WWW:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www.\yourdomain\.com)?$
RewriteRule ^(.*)$$1 [R=301,L]

That's it. 

Contact me if you have any questions.

~ John