On a recent project we had multiple duplicates of product detail pages mainly due to querystrings setting the sizes of the products. To combat this I decided to use the new Canonical REL URL tag now supported by Google, Yahoo and MSN and thought that if you’re experiencing the same issue that you’d appreciate this elegant solution to your own canonical url problems.
In the head just enter:
<link rel="canonical" href="http://www.website.com<?php echo $_SERVER['PHP_SELF']?>">
if you’re using a rewritten path then it needs to be changed to:
<link rel="canonical" href="http://www.website.com<?php echo parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);?>">
What this does is write in the url without the querystring in essence telling Google and the others that the non querystringed page is the one they should really index (googles supposed to 301 the links across).


Hi Mark,
i tried to integrate the canonical tag like you descripted it. Using Joomla 1.5.21 and the component sh404 (rewritten urls) I just get the following canonical tag: . I tried out both versions you posted, but it’s somehow not working for me. Do you perhaps know a solution for me?
Thanks in advance and all the best,
chris
PS: The domain ist named in the “Website” field of this comment.
i applied the one for rewrite urls and it worked like a charm, however, there is an issue. I added the code in my php file and now when i go to right url, it shows right url path, but when i go to wrong url, which is pulled from same php file, the canonical in viewsource shows the wrong path. e.g lower and upper case of urls.
same here! Any hack for that?