xml - Creating dynamic sitemap with php -
first let me tell learning php. want create automatically dynamic sitemap site. script (suppose sitemap.php) crawl links of site , create array of 1000 urls. once 1000 urls limit reaches, make page id 1000 urls array. script output :
<sitemapindex xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/siteindex.xsd"> <sitemap> <loc>http://exmaple.com/sitemap.php?page=1</loc> </sitemap> <sitemap> <loc>http://example.com/sitemap.php?page=2</loc> </sitemap> </sitemapindex>
page 1 have 1000 urls in xml format , page 2 have , go on site updated.i have tried many codes github , other seach pages google. have not found need. can please.
the best solution have access root folder , add apache .htaccess
file following line after rewriteengine on
rewriterule ^sitemap\.xml$ sitemap.php [l]
and having file sitemap.php
in root folder therefore accessible via http://yoursite.com/sitemap.xml
, default url search engines firstly search.
the file sitemap.php
shall start with
<?php header('content-type: application/xml; charset=utf-8') ?> <?php echo '<?xml version="1.0" encoding="utf-8"?>' ?>
i have solution , works charm :)
Comments
Post a Comment