On my website, a product page can be reached in different ways, eg:
www.example.com/gallery/details/product_1/category_1
www.example.com/gallery/details/product_1/category_2
www.example.com/gallery/details/product_1/category_3
As I guess these urls are duplicate content since they all show the same product page, how should I define a canonical URL to prevent google from penalizing the duplicate content?
Best way should probably be:
<link rel="canonical" href="www.example.com/gallery/details/product_1">
But users cannot follow this link as products are filtered by categories and one product may have several categories. Any help or suggestion would be greatly appreciated
You have two options:
Pick a default category that should be the one found in the search results. This probably should be the most popular (i.e. most searched for) category.
Make it so the URLs with no category works. It does not have to be found via your website (i.e. a category page or search functionality). It just has to be available.