Michael Samuel
Michael Samuel

Reputation: 3920

Dynamic Sitemap URL in robots.txt file

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?

Upvotes: 1

Views: 1018

Answers (1)

unor
unor

Reputation: 96737

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.

Upvotes: 2

Related Questions