Jump to content

[HACK] Prevent duplicate URLs to same product


Eck!

Recommended Posts

Ive just added this to my site to redirect incorrect (but working) URLs to the correct one via a 301. Google had indexed the incorrect ones for some reason. For example, both of the following URLs worked, the first was indexed by google instead of the second (the correct one):

/94-led-by-the-grey.html
/fantasy/94-led-by-the-grey-YPD00160.html

This works in PS 1.2.4 but I havent tested any other versions, nor have I tested it with non-SEO URLs, but it works great for me.

In product.php (root folder) round about line 120 just after where it says "/* rewrited_url set */"

       $defaultcategory = Category::getLinkRewrite($product->id_category_default, intval($cookie->id_lang));
       $plink = $link->getProductLink($product->id, $product->link_rewrite, $defaultcategory, $product->ean13);
       $request = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

       if(strcmp($plink, $request) !== 0) {
           header("HTTP/1.1 301 Moved Permanently");
           header("Location: $plink");
       }

Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 4 weeks later...

Thank you very much for your contribution. Can you fix all the duplicate url problems? ie the category duplicate url's aswel?

Have you told the admin team about your contribution? as it would benefit us all in the new version which shall be released

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...