You are here:  » Soft 404s


Soft 404s

Submitted by Halion on Wed, 2014-02-26 12:03 in

Hi David,

I have noticed a rise in soft 404s recently, related to brand and category pages where a brand or category has been removed or has less products in it after a feed update, and then google is reporting a 'The target URL doesn't exist, but your server is not returning a 404 (file not found) error. ', soft 404 error.
I'm using 12/10B, is there a way to add an additional statement so that a not found message is sent to stop these soft 404s?

Cheers
Mike

Submitted by support on Wed, 2014-02-26 12:45

Hello Mike,

To return a genuine 404 response, if you edit search.php (12/10B) and look for the following code at line 279:

  if ($resultCount)

...and REPLACE with:

  if (
     (!$resultCount)
     &&
     (isset($parts[1]) && $parts[1])
     )
  {
    header("HTTP/1.0 404 Not Found");
    exit();
  }
  if ($resultCount)

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Wed, 2014-02-26 14:20

Hi David,

Thanks for your reply. This seems to be working when the brand or category no longer exists, but if for example there are twelve products currently available for a brand, and at ten products to a page this makes two pages, page three and beyond I would like to return a 404 and go to the custom 404.php, but instead a 200 success is being returned, which means that if prior to the update there were, say fifty products for that brand or category, 404's should be generated for the pages where there are no longer products after the update. Hope this makes sense! Help would be appreciated.

Cheers
Mike

Submitted by support on Wed, 2014-02-26 14:34

Sorry Mike that was the intended functionality but I used the wrong variable in the test - correct replacement, and also including your custom 404.php page would be as follows:

  if (
     (!$numRows)
     &&
     (isset($parts[1]) && $parts[1])
     )
  {
    header("HTTP/1.0 404 Not Found");
    require("404.php");
    exit();
  }
  if ($resultCount)

Cheers,
David.
--
PriceTapestry.com

Submitted by Halion on Wed, 2014-02-26 15:25

Thanks David, this seems to work fine. (Apart from the Google Toolbar which when give navigation suggestions is ticked seems to nerf my 404 page, but this only applies to IE with toolbar and this option ticked, works fine on everything else - and is certainly outside the scope of PT support in my view, so don't worry I'm not asking for any help with that!!)

Thanks again for your peerless support in sorting out the soft 404 problem, I'll continue to monitor it and see how it goes.

Cheers
Mike

Submitted by keshavkshirsagar on Fri, 2015-08-21 12:43

Hello Sir

Can we set Product search result relevent to 404 page url content

Submitted by support on Fri, 2015-08-21 13:00

Hi,

For a no longer found product, Related Products should be shown, but of course would normally only be 3 results, so one thing you can do easily, is for expired products, increase number of Related Products results to same as normal search results.

To do this, edit products.php and look for the following code at line 113:

    $sql = "SELECT DISTINCT(name),MATCH name AGAINST ('".database_safe($q)."') AS relevance FROM `".$config_databaseTablePrefix."products` ".($ignoreFullText?"IGNORE INDEX (name_2)":"USE INDEX (name_2)")." WHERE ".$where." ORDER BY relevance DESC LIMIT 3";

...and REPLACE with:

    $limit = (isset($product)?3:$config_resultsPerPage);
    $sql = "SELECT DISTINCT(name),MATCH name AGAINST ('".database_safe($q)."') AS relevance FROM `".$config_databaseTablePrefix."products` ".($ignoreFullText?"IGNORE INDEX (name_2)":"USE INDEX (name_2)")." WHERE ".$where." ORDER BY relevance DESC LIMIT ".$limit;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com