woocommerce offtopic – Disable duplicate WC product category URLs
WC generates duplicate URLs when using category slugs.
Example:
demoshop.com/cat-1/product-a
The same product can be accessed from any URL if slug “cat-1” is modified, e.g.:
demoshop.com/modified/product-a will lead to a status code 200 as well.
From a SEO perspective this is not preferrable and I would like to modify the behaviour as follows:
If the product page is accessed via the correct url a 200 is sent.
If the product page is accessed via any other url a 301 to the correct url is sent.
If the product has muliple categories assigned, the primary one should be considered.
Any hints how to realize that?
Leave an answer