SEO URL Canonicalization

Posted On:
Filed Under:
By:
URL canonicalization

Website URL canonicalization is an important part of Onpage SEO Optimisation. When a website is indexed by a search engine they need to choose the best URL to index for that domain. A website can normally be accessed from a number of different URLs which all point to the same domain for example:

  • http://domain.com
  • http://domain.com/
  • http://domain.com/index.html
  • http://www.domain.com
  • http://www.domain.com/
  • http://www.domain.com/index.html

All the above will reach the same page. Internal links on your website to your homepage should all be consistent, same goes for the other internal pages. You need to decide which variation you want the search engines to index to make their job a little easier. If you are not consistent with links to your homepage on your website and in some cases if you have other websites linking to you with the wrong version of the URL then multiple versions can get indexed, meaning not all the ranking power is focussed in the one place - it is essentially split.

How can I fix my websites URLs?

Tell Google

Well you can first of all inform the mighty Google via the Google Webmaster Tools. Sign up, register and verify your website then under Site Configuration > Settings you then have the preferred domain setting where you can choose the URL variation you want. That isn't too much help for other search engines or websites linking to you, so how do you inform them? Read on...

Using a .htaccess file to fix URL Canonicalization

Well you don't actually 'inform' the others - you can use a .htaccess file to force them to be redirected to the correct URL so all variations all point to the one location. That way it doesn't matter how they link to you - the ranking power will all be focussed where you want it. My preference is to use the full version of the URL including the www and the trailing forward slash (http://www.domain.com/). Visit here for a comprehensive guide to creating a .htaccess.

To always include the www

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

To redirect /index.html to /

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ http://www.domain.com/$1 [R=301,L]

To always include the trailing slash

RewriteCond %{HTTP_HOST}   !^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://www.domain.com/$1 [L,R]