Issue Bug Closed

#97612Non-existing XML sitemap returns 200 OK instead of 404 Not Found

Chris Müller 05/12/22, 05:54 updated 10/04/22, 14:03

Description

Current behaviour:

Calling a non-existing XML sitemap like

https://example.org/?sitemap=nonexisting&type=1533906435

returns with status code “200 OK”. Additionally, the content type is “application/xml” but the content is not valid XML: “Oops, an error occurred! Code: 20220512054731023627ac Event: b5560739a1834fe0b83de86bbd5230ef” which results also in an parsing error when viewing in the browser (at least in Firefox).

The error is: PHP Warning: Undefined array key “somesitemap” in /var/www/html/typo3/sysext/seo/Classes/XmlSitemap/XmlSitemapRenderer.php line 111

The reason I encounter this error is because a configuration for custom records was removed as these records are not available anymore.

Correct behaviour:

A non-existing XML sitemap should return “404 Not Found” as status code. This also signals a search engine (or other crawlers) that this sitemap isn’t available anymore.

Steps to reproduce:

Add a new XML sitemap:

plugin.tx_seo {
  config {
    xmlSitemap {
      sitemaps {
        somesitemap {
          provider = TYPO3\CMS\Seo\XmlSitemap\RecordsXmlSitemapDataProvider
          config {
            table = pages
          }
        }
      }
    }
  }
}

Call the XML sitemaps overview with “?type=1533906435”

Click on the new sitemap: It is displayed.

Remove the above configuration.

Reload the new sitemap: The above error is displayed.

Remark: The cHash has to be correct, if the cHash does not match a 404 is already thrown.

Reviews 2