Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts

    sitemap.xml vs. sitemap.php?

    Firstly, I'm not sure where to put this post - i stuck it in here because it concerns XML. Sort of ...

    Let us imagine that I have a website who's content changes regularly (e.g. I have a blog publishing engine on the website - new articles are added frequently) and, once a day via a cron job, I auto-generate a sitemap and stick it in a database. I then have a script called sitemap.php which retrieves the sitemap and displays it with the appropriate XML header - its header and content are therefore indestinguishable from the equivalent sitemap.xml file.

    BUT ... will webcrawlers recognise sitemap.php or will they look only for sitemap.xml?

    I.e., will I need a mod rewrite in .htaccess?

    EDIT: I don't want to write sitemap.xml directly to the root dir, because that would require write permissions to be applied to the root directory, which is asking for trouble ...
    Last edited by XmisterIS; 06-08-2012 at 10:16 AM.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,631
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Add a line to your robots.txt file identifying where to find the sitemap.

    Sitemap: http://example.com/sitemap.php
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts
    Thanks for the info, my question was more along the lines of, is the .php extension just as acceptable to all webcrawlers as the .xml extension when looking for a sitemap? (.e.g google)

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,631
    Thanks
    0
    Thanked 648 Times in 638 Posts
    Quote Originally Posted by XmisterIS View Post
    Thanks for the info, my question was more along the lines of, is the .php extension just as acceptable to all webcrawlers as the .xml extension when looking for a sitemap? (.e.g google)
    All the major search engines will use whatever file you specify in your robots.txt

    The sitemap I use has a .xml.gz suffix because it uses a compressed format (created using a Python sitemap generator written by staff at Google).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    XmisterIS (06-08-2012)

  • #5
    Regular Coder
    Join Date
    Jun 2010
    Posts
    293
    Thanks
    63
    Thanked 8 Times in 8 Posts
    great! thanks.

    On a slightly different note (and I am aware that this thread is now moving significantly away from XML!), will the following generate output that Google and other crawlers will understand? (Note - I got the headers from http://mail-archives.apache.org/mod_...alex.com.pl%3E)

    PHP Code:
    $sitemap getSitemapFromDB();

    header('Content-Type: application/x-gzip');
    header('Content-Encoding: identity');

    echo 
    $sitemap;  //Encoded prior to DB storage using gzencode($sitemapData, 9, FORCE_GZIP); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •