php

XML Sitemap Generator Script in PHP for Google and others

Posted on

We develop a lot of websites and quite rightly the owners want their site to appear in Google as quickly as possible. One way to speed up this process is to use Google’s sitemap tool.
Google accept sitemaps in various formats, one of them being XML.
Now if you have a site, or develop websites, that quite often have new content and pages being added to them it can be a pain to create a new sitemap each time. For this reason we have taken a nice little script developed in ASP by Francesco Passantino and rewritten it in PHP.
To use this script, simply place it in the root of your website and tell Google where it is in the Add Sitemap section of Google sitemaps.
The script will generate a valid XML sitemap that will dynamically update whenever new pages are added or pages are deleted.

Version 1.0 can be found here. This is for PHP5 only, we also have a PHP4 version which can be found here. To use the PHP4 version you will need the strripos PHP4 script from here.

This entry was posted in Search Engine Tips, Useful Tools, Web Development. Bookmark the permalink.

6 Responses to XML Sitemap Generator Script in PHP for Google and others

  1. I can’t find any installation instructions, please help me get it to work. Thanks!

    • WebMe says:

      Hi.
      Third paragraph:
      To use this script, simply place it in the root of your website and tell Google where it is in the Add Sitemap section of Google sitemaps.
      Remember you’ll have to change the extension to .php.

  2. WebMe says:

    We have identified a bug with the script. It is not very happy with sub-directories. We will publish an update shortly.

  3. Hi,
    I uploaded sitemap.php on my host and run this script, but error.
    Warning: fopen [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Component not found in on line 65

    Warning: feof(): supplied argument is not a valid stream resource in on line 67

    • WebMe says:

      Make sure that fopen and cURL are not restricted on your hosting platform.
      I know that some shared hosts put a restriction in that means you cannot make connections back to the same server. We have a fix for this which I will upload soon.
      In the meantime you need to crawl the path rather than URL.

  4. Joseph says:

    don’t want to work for me !!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>