Canonical URLs and how to avoid them using redirects.
April 28, 2007Sometimes if domains are incorrectly setup, the domain urls www.domain.com and domain.com are considered by search engines as separate pages. As both pages are indexed by search engines, you may be penalised for duplicate content (bad).
To avoid this, you can redirect all traffic to one standard URL, a canonical URL. Canonical means ’standard’ or ‘authoritative’
I’ve implemented two simple methods around this.
1. Mod Rewrite in .htaccess
This is apache server specific, create or amend your .htaccess file with
RewriteEngine On
RewriteCond %{HTTP_HOST} ^barryhand\.com$ [NC]
RewriteRule ^(.*)$ http://www.barryhand.com/$1 [R=301,L]
This enables the Rewrite Engine (line1) while a condition on line2 comes into play when people access barryhand.com , this is also case sensitive [NC]
The 3rd line redirects to www.barryhand.com using a permanent 301 redirect
2. Google Preferred Domain
Google allows you to control your preferred domain from their excellent webmaster tools section. A whole host of goodies and stats are also available once you verify your site ownership.
Enabling both these methods will assist in search engine optimisation , for more information see here -
