sitemap.php to sitemap.xml htaccess file

Google can get lost or confused when browsing your website, a perfect example of this is my website there is really only a few pages that make up the whole site. However there is actually quite a lot of content and information in the database that Google could do with indexing, unfortunately you have to type a parameter such as “80” to see this information.

Sitemaps as the name suggests is just a Map to your website, basically your creating a sitemap.xml that will give the search engine a list of places it should look when trying to index your content.

As my website is built in php it made sense to use this to create the sitemap, so I created a file called “sitemap.php”. However search engines look for sitemaps that are called “sitemap.xml” as you output them in XML.

A simple work around for this is using a .htaccess file to rewrite your .php URL to a .xml URL, here is what I used:

Options +FollowSymlinks
RewriteEngine On
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]

Technology enthusiastic with many ongoing online projects one of which is this personal blog PingBin. While also working full time within a data center designing and maintaining the network infrastructure.

Leave a reply:

Your email address will not be published.