Hi,
I want to create a dynamically created xml file with php. Is it possible to just create it as normal and call it something like sitemap.php and then use a .htaccess file to change the name to sitemap.xml?
Thanks
| SitePoint Sponsor |
Hi,
I want to create a dynamically created xml file with php. Is it possible to just create it as normal and call it something like sitemap.php and then use a .htaccess file to change the name to sitemap.xml?
Thanks

Use .htaccess to make it parse the .xml file as PHP:
Code:<Files sitemap.xml> ForceType application/x-httpd-php </Files>
John Conde | Facebook | Twitter
Brainyminds Merchant Account Services I Love Code eBook Giant
Authorize.Net: AIM API | ARB API | CIM API Get the FREE code!
Merchant Accounts 101 | Ecommerce 101
yup - using mod_rewrite.
It doesn't have to have the xml extention, though, you just need this line at the top:
and any browser/search engine/bot will see it as an xml file.PHP Code:header("content-type: text/xml");
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Thanks, the .htaccess file is doing the job now. Im a bit confused about what to do next.
I though i could leave my sitemap file as it is and just echo whats their already and then just add in the mysql queries to pull all the new pages from my database but im getting a parse error. How do i go about formatting it?
what's the parse error?
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Ahh, got that error sorted.
You can view the sitemap here:
*removed
If you look at the source it looks like it should be formatted. Is it ok when it appears like this?
Thanks again!!
Last edited by Banana Man; Oct 12, 2007 at 13:40.

Looks like it is spitting it out as plain text and not XML> Make sure you use the headers in this post.
John Conde | Facebook | Twitter
Brainyminds Merchant Account Services I Love Code eBook Giant
Authorize.Net: AIM API | ARB API | CIM API Get the FREE code!
Merchant Accounts 101 | Ecommerce 101
Nice oneDoing the job now. You's had given me all the info but i just didnt know how to implement it properly. Thanks for help!!
The file's returning an error at the moment, at the bottom.
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
doesn't matter - you've fixed it now.
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Yeah, just messing about with the mysql output. I'll get their in the end![]()
Bookmarks