You are here:  » Getting rid of a non-existing sitemap

Active Forum Topics


Getting rid of a non-existing sitemap

Submitted by 2fer on Mon, 2018-08-06 18:09 in

Hello David,
I'm still on 13/03A and have a basic question. I searched through the first 3 pages of results, but not all 10 and didn't find the same situation. This is probably a server config issue and not related to the sitemap.php file, but it doesn't serve a 404 when there is no feed present. One merchant I had on one site closed their program and I removed the feed and deregistered it, but Google keeps telling me about a sitemap error.

If I visit the URL myself, I see <urlset/> when I'd expect to see a 404 error. But when I used the same sitemap URL as reported in GSC and I changed the sitemap URL to example.com/shop/sitemap.php?filename=gdrtekcuso.txt (made-up gibberish) it returns the same <urlset/> as the actual former sitemap does.

The PT shop is not in the root folder and I don't manage the httpd.conf file, so is there anything like an "if" function for sitemap.php that would deal with gone and/or unreal requests?

Thank you for all the great assists over the years.
2fer

Submitted by support on Tue, 2018-08-07 08:06

Hello 2fer,

It's no problem to return 404 for merchants that no longer exist - to do this, edit sitemap.php and look for the following code at line 2:

  require("includes/common.php");

...and REPLACE with:

  require("includes/common.php");
  if (isset($_GET["filename"]))
  {
    $sql = "SELECT normalised_name FROM `".$config_databaseTablePrefix."products` WHERE filename='".database_safe($_GET["filename"])."' LIMIT 1";
    if (!database_querySelect($sql,$row))
    {
      header("HTTP/1.0 404 Not Found");
      print "<h1>404 Not Found</h1>";
      exit();
    }
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by 2fer on Wed, 2018-08-08 05:26

Wow! Thanks, David, I'll get that up right away.
Thank you!
2fer