URL Canonicalization for SEO
Okay, I know url Canonicalization sounds really technical and confusing, but truthfully it is an easy concept to understand. Not to mention it is very important for Search Engine Optimization (SEO).
First lets define URL Canonicalization as the process of establishing a single URL as the location of a web document. The web document being a page on your website. So what does “establishing a single URL” mean?
When it comes to SEO, search engines look at a URL with “www” in it differently than a URL that does not have “www” in it. For example, in Googles eyes, http://www.yoursite.com is a different URL than http://yoursite.com.
Why does this matter? Well mostly because of inbound links, which are very important for SEO. If you get one company who links to your site by putting in the “www” and another company who doesn’t use “www”, your link equity will be split. Because of this you will not be driving as much link juice to your pages as you possibly could.
The idea is to generate one URL for all occasions, so no matter what they type in or link to it goes to one location. The way that you do this is by 301 redirecting non “www” to the “www” version of the URL. Or in some cases vice versa, depending on what you want.
If your site is written in PHP you will most likely have a file called .htaccess. In this file is where you create the redirects. See below for the two scenario’s. The following code should be placed at the top of your .htaccess file. Make sure to save a copy of your current .htaccess file in the event you screw something up.
#redirect from non www to www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com [NC]
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
#redirect from www to non www
##www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^yoursite\.com [nc]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
Hope this helps you on your quest to ranking higher on the search engines.
I’d wondered whether Google differentiated between having and not having the www in one’s domain name. Thanks for sharing your knowledge, Brett.
Thanks Navpreet for the comment. Yes they do, they also view yoursite.com/index differently than yoursite.com.