1

I have the following content in my robots.txt file:

Sitemap: https://example.com/sitemap.php

Is it ok to have the sitemap in robots.txt as .php file instead of .xml as I generate it dynamically?

Michael Samuel
  • 3,820
  • 12
  • 45
  • 85

1 Answers1

2

A consumer (like a search engine bot) can’t know if a file is static or dynamically generated, it could only guess (e.g., based on the response time, HTTP response headers, or the URL design).
You could have a static file named sitemap.php, and you could have a dynamically generated file named sitemap.xml.

And a consumer doesn’t need to know. What matters is the content of the file, not how the file was/is created, not its URL.

In any case, make sure to send the correct Content-Type for this file. Some servers automatically select a content type based on the filename extension, which would fail with .php, so you might have to set it explicitly.

unor
  • 92,415
  • 26
  • 211
  • 360