I've recently made some big changes to my site and as a result, have had to change my sitemap. In doing so, I resubmitted my sitemap file only to see 3 errors reading invalid URL's. I'm not sure if it's worth mentioning or not that my sitemap file ins't actually a true XML file. Rather, it's a dynamic php file that the server is tricked into believing is an XML file thanks to modrewrite. This didn't matter last time as I had no sitemap errors. But, this time it is.

Here is a pic of the error

The actual sitemap can be found here

The sitemap.php file starts like this:


echo '<?xml version="1.0" encoding="UTF-8"?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
       Continued ............

1 Answer 1


I see the following problems:

  • Your server return the wrong content type for the sitemap. It returns Content-Type: text/html when it should return Content-Type: application/xml
  • Your XML sitemap starts with a new line character. This makes the XML document invalid. When I run it through xmllint I get the following error: sitemap.xml:2: parser error : XML declaration allowed only at the start of the document

I doubt that the wrong content type is throwing Google off, but it is probably worth fixing.

The new line at the beginning of the document should be fixed. If you are serving it via PHP it could be caused by PHP header information that you have in the document that doesn't get printed. Once I remove the new line at the beginning, xmllint does not report any more problems.

  • I posted the beginning of the sitemap file in the hopes that it'll clear things up in regards to the error on line 2.
    – Lance
    Commented Mar 19, 2013 at 20:04
  • It is likely that one of the libraries in the require_once directives is causing the new-line to be printed. I have seen extra new lines at the end of the file after the ?> that cause the problem. Commented Mar 19, 2013 at 20:09
  • Unfortunately, the internet that I have at school wont let me connect to my remote server via ftp to overwrite the sitemap file. So, I won't be able to find out if the new file is valid using google's webmaster tools. But, as soon as I get home tonight I'll let you know how your advice has worked out. Thanks a bunch.
    – Lance
    Commented Mar 19, 2013 at 20:12
  • I think the problem is with the files that are being required. What could it be in those files that's throwing an error? Could it be comment tags?
    – Lance
    Commented Mar 20, 2013 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.