<link rel="canonical" href="http://www.example.com/category/subcategory/example-product/product-id" />

I have a whole bunch of query string URLs (company products) that I have rewritten to friendly ones (such as that indicated above). At present, seems search engines are still seeing both versions, so I thought perhaps I should add the canonical tag to my preferred URL.

Incredibly, days and days of trolling god-knows-what web development resources on the internet has not clearly answered the question of "how" for me. Hoping someone here can help.

For the record, I am utilizing a single file (products1.php) to populate all of my products.

1 Answer 1


products1.php simply needs to output the canonical link in the head section of the page. Presumably it knows the information needed to build your friendly URL:

  • category
  • subcategory
  • product name
  • product id

Then the canonical tag appears in both the page for the friendly URL and the page for the parameterized URL. That is fine. Google says that a canonical link that points to the current page would be OK.

  • So then I would render the canonical link in the tag as: "example.com...""?? Nov 19, 2014 at 20:51
  • You would use the full friendly URL including http and the hostname Nov 19, 2014 at 21:05
  • But there's dozens of friendly URL's because I have dozens of products. I'm obviously dense, can you clarify? Nov 19, 2014 at 21:13
  • Since the page is dynamic the script would build the matching canonical url for the current product Nov 19, 2014 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.