URL Canonicalization, How to write an .htaccess file.
by admin
Canonicalization is a big word, essentially meaning standardization or normalization. In the context of SEO, it’s best described by Wikipedia.
URL normalization (or URL canonicalization) is the process by which URLs are modified and standardized in a consistent manner… wikipedia
Even more simply, it’s a set of rules written in regular expressions that instruct browsers to redirect your site from http://yourdomain.com to http://www.yourdomain.com (or the opposite, I like the www – but it doesn’t matter in the practical sense)
The point is to make sure that all links resolve to one url. By default, there are four possible versions of your home page that someone could link to.
http://yourdomain.com
http://www.yourdomain.com
http://yourdomain.com/index.php (or html, or htm)
http://www.yourdomain.com/index.php (or…)
That’s at least four. Some content management systems, like Joomla, create multiple links your home page – so it’s not unreasonable to have more than four.
Canonicalization, in my opinion, is an effort of vanity. Google won’t penalize you for having multiple links, and I’ve not seen a lack of proper canonicalization affect the typical small business site adversely. Still, if you have the time, it’s worth the ten minutes it takes to set this up.
Here’s how to canonicalize your site to resolve to the ‘www’ version
1.Open up an FTP client and navigate to the public_html directory of your website (I use FileZilla)
2. Download the .htaccess file
3. Insert the following code (replacing yourdomain.com with your own site)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com%{REQUEST_URI} [R=301,L]RewriteBase /RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html|php)\ HTTP/
RewriteRule ^(([^/]+/)*)index\.(html|php)$ http://yourdomain.com/$1 [R=301,L]
4. Upload the file to the public_html directory.
That’s it, your site should resolve properly. That didn’t take long, did it?
If you’re especially lazy, you can download my htaccess sample script - just remember to change yourdomain.com to your sites URL before you upload it.
Have a more complex situation? Contact me for help or post a comment below.
