recently i had to create a sitemap for google. but i didnt want to have to have an xml file that was not updated as soon as i added more urls

for example, if i have a forums and each day, i have new urls added to my site, so i wanted to add these urls to my sitemap so that when google crawls my site, it would include the new urls

well, if you have the same situation as i do, maybe you can benefit from my learnings. these are the things you are going to needs:

1. php hosting (if you dont have php hosting, you can visit our friends at www.webune.com)
2. hosting with apache mod_rewrite

thats all that will be required.

now i will show you step by step on how to achieve this. first lets start by creating a new folder or directory in your website to test this. lets call it "test"

1. the first step is to open your text editor. since i am using windows xp, i will use notepad for this tutorial. so open a blank notepad and copy and paste the following:

htaccess File:
RewriteEngine On
RewriteRule sitemap.xml sitemap.php [L]


now save it as ".htaccess" in your test folder
20081129_6815_xml-htaccess.gif

2. now on step 2 we will create the php file. here is just an example, you can create your urls from your database. but for the purpose of this tutorial, open a new notepad and copy and paste this code into it:

PHP CODE:
<?php
header( "Content-type: application/xml; encoding=UTF-8",true );
header( 'Pragma: no-cache' );
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.wallpaperama.com/</loc>
<lastmod>2008-11-29</lastmod>
<changefreq>monthly</changefreq>
<priority>0.8</priority>
</url>
</urlset>';
?>


now save it as sitemap.php in your test folder.

now upload the directory "test" and the two files .htaccess and sitemap.php. once you have uploaded to your site, open it using your browser. for example: http://www.example.com/test/sitemap.xml

now when you open it, you will see the xml content:
this is what you will see:


This is with Firefox:
20081129_6815_xml-firefox.gif

this is with internet explorere:
20081129_6815_xml-explorer.gif

hope this helps