Translate

Sitemaps Content-Type Header

(Redirected from Sitemaps-contenttype-header)

There are only few things which may prevent a site being correctly indexed when that uses a sitemap and sometimes the simple conclusion is that even though the sitemap’s markup is absolutely correct, not even browsers recognize it as an XML file.

This issue may appear if you generate the sitemap dynamically using server side code and roots in the fact that the output buffer’s Content-type header by default is set to text/html but an XML file’s should be text/xml.

Note that defining XML markup on the beginning of the sitemap is not enough alone.

To correct this issue you will have to send to the browser the following header, before writing anything to the screen:

     Content-type: text/xml


In PHP you would do this the following way:

header('Content-type: text/xml');


In ASP, the following method works:

response.ContentType="text/xml"


Perl:

print "Content-type: text/xml\n\n";


And finally, in Python, just like in Perl’s case:

print "Content-type: text/html\n\n"