5

I've written a script in PHP that generates a XML sitemap. It has a text/xml header and outputs a XML structure. Can I upload this sitemap.php file to Google or is it required to have a .xml extension?

4
  • 1
    You need to use some rewrite rules (.htaccess or similar for other webservers) and rewrite the .xml to your .php. Then set the correct headers in your php script and it should work.
    – smottt
    Sep 5, 2012 at 9:13
  • Assuming you're using Apache, you could make a Location rule that processes /sitemap.xml through the PHP engine. (Edit: yep, see @smottt above!).
    – halfer
    Sep 5, 2012 at 9:14
  • don't forget to read sitemaps.org :)
    – shail
    Sep 5, 2012 at 14:07
  • Just try your own, google will tell you if it works or not: support.google.com/sites/answer/100283?hl=en
    – hakre
    Jul 15, 2014 at 17:23

1 Answer 1

2

Check out http://www.sitemaps.org/.

All rules are defined here.

Exemplary see:

All you need is an URL, then announce that URL as your sitemap.

There is no .xml requirement in the protocol itself.

It's common to place it at the root as http://example.com/sitemap.xml, but read the reference documentation for all details, you're not required to, there can be good reason to not do so and the location of the sitemap file has implications about it's contents. So better read and chew a bit on it to find the best solution for what you're trying to do.

1
  • It doesn't mention if it has to be given an .xml extension
    – moobot
    Jun 14, 2013 at 3:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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