3

Do XML sitemap files have to end with the .xml file extension?

On the Bigcommerce platform, their XML sitemap file are defined as:

http://www.examplesite.com/xmlsitemap.php

The sitemap file is all correctly marked up and and when saving locally its saves as an .xml file. I've also seen some Joomla sitemap plugins create sitemaps with .php extensions.

The Sitemap Protocol site doesn't cover this.

I unfortunately don't have access to GWT too see if it verifies.

2
  • Don't forget to approve an answer if you like it, thanks! Commented Aug 25, 2014 at 17:34
  • Use an HTTP router like github.com/nikic/FastRoute and create a route that matches "/sitemap\.xml", then you render a xml response.
    – marcio
    Commented Aug 19, 2015 at 7:54

2 Answers 2

4

It has been verified that a PHP file can be used as a sitemap file such as sitemap.php

  1. I checked http://sitemaps.org (the website with the specification information for sitemaps) and there is no mention that the file must be saved in the .XML format. I will have to say that yes, it will work, as long as Google does not have a problem with the extension for some reason.

  2. When you go through Google Webmasters Tools and click on submit/test a sitemap you are prompted with your site's root directory http://example.com/ immediately followed by a text field you can enter any file name and extension into; with no file extension forcing you to use an actual "XML" file here I'm assuming that you can use a sitemap with a .PHP extension.

2
  • 2
    I can confirm that works, I had to a dynamic sitemap once and ended up writing a php script to generate the xml. Have tried this with GWT and BWT both. Commented Jun 14, 2013 at 6:52
  • But does it need to be served with an XML mime type i.e. text/xml? Commented Jun 15, 2013 at 17:18
1

I gzip my sitemap to mymap.xml.gz and it works fine when I declare it so in my robots.txt. If you have a Google Webmaster Tools (GWT) account, GWT will tell you if there is any issue with your sitemap.

So, no, the extension does not have to be .xml.

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.