Crazy word, I know. Anyway, I am going to keep this post fairly short and try not to be super technical, but I think it is impossible in this one. So, here we go.
First let’s start with the definition of what canonicalization is:
Quoted from Matt Cutts blog
“Canonicalization is the process of picking the best url when there are several choices, and it usually refers to home pages. For example, most people would consider these the same urls:
* www.example.com
* example.com/
* www.example.com/index.html
* example.com/home.asp
But technically all of these URL’s are different. A web server could return completely different content for all the URL’s above. When Google “canonicalizes” a URL, we try to pick the URL that seems like the best representative from that set.” – Matt Cutts
So, with that said, you may ask yourself, how do I do it? Well, here are a couple ways that you can do it:
FOR DYNAMIC PAGES- (A dynamic page is one generated by a database driven application, like a blog or forum)
A file name is appended by a string- it will look like this (just like on your Wordpress blog
):
http://www.example.com/page.php?id=20
Where a query string is used the normal static 301 redirect won’t not work; you’ll need to use a rewrite solution. Using the page.php?id=20 example, here’s what you’ll need to use in your .htaccess file (usually found in the root):
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=20$
RewriteRule ^/page.php$ http://www.example.com/newname.htm? [L,R=301]
In the example above the id=20 should be replaced with the string of the page you wish to redirect and the page.php with the name of your file prior to the string.
Remember, you must have mod_rewrite enabled for this to work. Consult your Apache manual for that…if you don’t know what I am talking about then you won’t know how to do it anyway. Call your web host.
*****There is a shortcut if you have CPanel installed- go to Domains>Redirects then go through manually and redirect everything to your canonical homepage….post a comment if you need help and I will give you a hand*********
FOR STATIC PAGES-
This is as easy as it gets for 301’s.
Just open up your .htaccess file, and then add this line:
redirect 301 /olddirectory/oldpage.htm http://www.yoursite.com/newpage.htm
Just replace the obvious to make it fit your site. DO NOT ADD HTTP:// to the first part of it. Don’t ask why, just don’t do it…just type in the path.
OK- So that is how I “get er done”. If you have another way or something to add to this, then feel free to comment with whatever you think is necessary. This post is just a run of the mill, “how to” kind of thing- not an authority on redirects. Visit W3C.org for that.