0

I am creating a web application using php. I want to create a sitemap for my application. I dont know how to create that xml file and how to include in php. And also I want to know that, is it possible to check that in my localhost before upload into my hosting server? I want a simple example code to create the sitemap.xml file and how to link that in php page? Please, does any one can help me?

3
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by rajilakshmi
1

If your pages are stored in the database, then you can generate your sitemap easily from a query. It depends on how your website is built.

1
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://mysite.com/</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Weekly</changefreq>
        <priority>0.9</priority>
    </url>
    <url>
        <loc>http://mysite.com/about.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>http://mysite.com/something.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Daily</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>http://mysite.com/contact.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Monthly</changefreq>
        <priority>0.6</priority>
    </url>
</urlset>

not sure what youre trying to test locally but your sitemap don't mean much on a local server so you can open it and check for errors but thats about it. you can hardcode the sitemap in your php or convert the sitemap using regex but thats a pain in the ass. I think there are frameworks that can handle that but your better of hardcoding it in an unordered list

Edited by moneeshot

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.