索引规范版本页面的正确方法是什么?

A client has a site where the URLs have a parameter for related products. For instance, the page for product A has been indexed as:

www.website.com/A

but also as

www.website.com/A?related-to-B

and

www.website.com/A?related-to-C

etc.

The content for all these URLs is exactly the same, which causes duplicate content issues and a number of total indexed pages which is about 10 times his real amount of pages.

How can I tell Google to 301 every indexed page that has ?related-to-X back to the page without it? The website is in PHP.

(I assume this is a problem many have encountered before through affiliate links, so I guess the solution should include modifying the HTTP headers)

Adding a rel=canonical will mostly work, but from my own experience, Google sometimes still indexes the duplicate files.

If possible, a 301 redirect is a better solution from an SEO-perspective.

Either way, try to limit links to the duplicate files.

If you try the canonical solution and it does not work, then you can consider blocking the duplicate pages either via a meta robots=noindex or in the Google Webmaster Tools parameter handling section.