Using the Link Rel Canonical Tag - Theory of Implementation (
Page 2 of 5 )
To understand how to implement this, we must illustrate first how 301 redirection is used to solve this type of problem. Consider the example below, which illustrates a typical non-www and www canonical issue:
Googlebot sees a non-www URL during a crawling session ---> http://somewebsite.com/myfile.php ---> if non-www ---> server will do a 301 redirect to the www canonical version ---> http://www.somewebsite.com/myfile.php ---> Googlebot indexes the www version
Therefore, this means that if Googlebot sees any non-www URL, the server will do a 301 redirect so that Googlebot will index the canonical version.
What should happen when we use the link rel canonical element? See the diagram below:
Googlebot sees a non-www URL during a crawling session ----> http://somewebsite.com/myfile.php ----> Google sees the link rel canonical tag in the head section of this file <link rel="canonical" href="http://wwww.somewebsite.com/myfile.php" /> ------> Google indexes the canonical URL provided.
This means that we have to place this tag in the <head> section so that if any non-www URL is being crawled, Googlebot will fetch the canonical www URL.