1

I have a sitemap named http://www.domain.com/sitemap1.php. It starts with this code:

<?php
echo '<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd"        xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
';

After moving from Apache to Nginx Google webmaster tools started to refuse my sitemaps telling me that they look like HTML pages.

When looking at the output I saw something strange.

With Nginx:

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><head/><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

With Apache:

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="http://www.weddingpages.nl/sitemap.xsl"?><urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/09/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

For some reason I do not understand Nginx throws in

<head/>

right before urlset.

Does anybody know the reason for this ? I am afraid this is what causes the problem. But even after searching I didn't find the answer.

1 Answers1

1

I do not know if it is right to answer my own question. But after some days I finally found the solution.

I want to thank Alexey Ten for mentioning the word "module". It seems the pagespeed module is the problem. Disabling pagespeed in the nginx configuration files solved the problem. I've read pagespeed only changes html so probably pagespeed thought this xml output was html. I enabled pagespeed again and added:

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

in the .php files. Now everything works allright. The strange thing is that I also used Apache with the pagespeed module and never had this problem. Probably there is a difference in pagespeed behaviour with Nginx compared to Apache.