Dynamic php site map

We wanted to share this code for several reasons.
1st of all we wanted to give an example to potential clients of a simple WordPress customization with great results.
2nd We wanted to give back to a great open source group.
Finally, this is a great script and can be used many ways. The script will almost always improve an indexed websites SEO. The reason for this is it’s ability to fix broken links on your server instantly.

The script will work on any server that runs php 5 and works with any google compliant sitemap.

We will go over the different implementaion options after showing you the code.
Download sitemap.zip

Now decide your choice of implementation…
If you’re using WordPress:

1) Open the 404.php file in your theme folder. if, it’s not located in your theme then goto the defualt theme folder and copy it to your theme folder.

2) It normally says 404 error in header 2 i.e.
<h2></h2>.
Delete the h2 and paste the code below. If you have a custom 404 page and want some other text there place the code below where you want the site mape to show up.
//call sitemap.php file
incmµçVFR'6—FVÖç‡#°£Âö6öFSà

Or you can use your htaccess file to call a custom error page:
1) create or open .htaccess should go on the www root.

2)place the code below in the .htaccess file. change the sitemap.php location or name if needed.
ErrorDocument 404 sitemap.php
Don’t think that this script only works for error pages. You can use this on any page you choose. just include the php file as shown above.

Veiw an example of the dynamic sitemap.
If you have any questions please leave a comment.

Thanks!
Peak Studios
Staff

8 Responses to “Dynamic php site map”

  1. Keith Says:

    This tutorial works great on website. It helps customers get to their correct place if they accidently get directed to the wrong page.

  2. Quince Says:

    I have made some revisons to this to add functionality and higher SEO ranking. Try adding link rel and id tags for every line with an additional link that moves you to the link. I added the code into the main post code.

    Thanks!
    Quince Wyss
    Peak Studios

  3. Joe Says:

    I have tried using this code on my website and it seems like most search engines are ranking my page higher.

  4. Janet Says:

    Very cool!

  5. Lindsay Says:

    This is the best type of 404 page I have seen. Its great for SEO and creating links.

  6. Jared Says:

    This new sitemap/404 page is nice because it helps search engines index my pages very quickly.

  7. Alex Says:

    Does Google scan the links on 404 pages?

  8. Brad Says:

    I like this new usage of 404 pages for something more interesting.

Leave a Reply

You must be logged in to post a comment.