You are here:  » Returning a 404 message on old jump.php redirects


Returning a 404 message on old jump.php redirects

Submitted by serviendo on Mon, 2009-10-19 10:52 in

Hi David

Is there a way to amend my jump.php file so it returns the correct http response, and a message to the user if a retailer link (e.g. jump.php?id=123456789) no longer exists.

I realise I can add 'rel=nofollow' and disallow in robots.txt to stop Google indexing them, but I also feel that returning the correct response, and a message to the customer is the right thing to do.

Many Thanks!

Submitted by support on Mon, 2009-10-19 12:22

Hi,

Sure - in jump.php you will find this code on line 6:

  database_querySelect($sql,$rows);

...simply REPLACE that with:

  if (!database_querySelect($sql,$rows))
  {
    header("HTTP/1.0 404 Not Found");
    require("404.html");
  }

In addition, create a new file - 404.html in the same directory as jump.php containing the HTML of a page you wish to display when a link no longer exists.

(note that these pages shouldn't be appearing on your site live, so I guess these are cached pages that are sending users to invalid jump IDs...)

Hope this helps!

Cheers,
David.

Submitted by serviendo on Mon, 2009-10-19 12:26

Yes they are cached links in Google.

Great solution as always, thanks David.

Submitted by Rocket32 on Wed, 2014-08-06 22:48

Is there a way for the jump urls to never change for same existing products after a new feed import & And all newly added products get a new jump url & products that no longer exist get the 404.html page?

Submitted by support on Thu, 2014-08-07 08:50

Hi,

Sure - you can link to jump.php with the dupe_hash which will always be identical for the same (merchant + product name) combination. To do this, first edit jump.php and look for the following code at line 4:

  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id='".database_safe($_GET["id"])."'";

...and REPLACE with:

  $sql = "SELECT filename,buy_url FROM `".$config_databaseTablePrefix."products` WHERE dupe_hash='".database_safe($_GET["id"])."'";

And then in includes/tapestry.php look for the following code at line 101:

  return $config_baseHREF."jump.php?id=".$product["id"];

...and REPLACE with:

  return $config_baseHREF."jump.php?id=".$product["dupe_hash"];

Cheers,
David.
--
PriceTapestry.com

Submitted by Rocket32 on Fri, 2014-08-08 02:27

Works fine on products.php page when linking out to merchant's site. But when using the search.php it gives a blank jump id & broken page error. My search.php is linking direct to merchant on searches. Jump is empty on these pages.

Submitted by support on Fri, 2014-08-08 08:39

Hi Rocket32,

Ah sorry about that - the dupe_hash field isn't included by the search SELECT sql so that needs to be added, that's all. In search.php look for the following code at line 374:

      $sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

...and REPLACE with:

      $sql2 = "SELECT id,name,normalised_name,image_url,description,price,rating,dupe_hash FROM `".$config_databaseTablePrefix."products` WHERE id IN (".$in.")";

Cheers,
David.
--
PriceTapestry.com

Submitted by Rocket32 on Fri, 2014-08-08 11:18

Jump id is still coming back blank on search results.

Submitted by support on Fri, 2014-08-08 11:23

Hi Rocket32,

Please could you email me your:

search.php
html/searchresults.php
includes/tapestry.php

...and I'll check that all out for you.

Cheers,
David.
--
PriceTapestry.com