网站地图生成代码
<?php
$dom = new DOMDocument("1.0", "utf-8");
header("Content-Type: text/xml");
$root = $dom->createElement("urlset");
$dom->appendChild($root);
for ($i = 0; $i <= 998; $i++) {
$track = $dom->createElement("url");
$root->appendChild($track);
$loc = $dom->createElement("loc");
$track->appendChild($loc);
$lastmod = $dom->createElement("lastmod");
$track->appendChild($lastmod);
$changefreq = $dom->createElement("changefreq");
$track->appendChild($changefreq);
$priority = $dom->createElement("priority");
$track->appendChild($priority);
$text = $dom->createTextNode('http://www.baidu.com/' . (mt_rand(1,20)) . ($i+1) . '.html');
$loc->appendChild($text);
$date = date("Y-m-d", strtotime('-' . rand(0,10) . 'day'));
$text = $dom->createTextNode($date);
$lastmod->appendChild($text);
$text = $dom->createTextNode(daily);
$changefreq->appendChild($text);
$text = $dom->createTextNode(0.8);
$priority->appendChild($text);
}
$dom->save("sitemap.xml");
exit;代码说明
hangefreq:页面内容更新频率。
lastmod:页面最后修改时间
loc:页面永久链接地址
priority:相对于其他页面的优先权
这样就可以在你的网站根目录下生成sitemap.xml文件
sitemap
2023-10-14 182sitemap是网站地图,sitemap可以让搜索引擎更简单的了解网站结构,并能让搜索引擎蜘蛛快速爬取到网站的主要内容.所以sitemap是网站优惠非常重要的一步,这里我的站...
- WordPress禁止用户访问sitemap,只允许搜索引擎蜘蛛访问方法 [2023-10-14]
- 百度XML地图一键推送工具 [2023-07-30]
- PHP生成sitemap网站地图代码 [2021-09-22]
- 自动生成sitemap地图php代码 [2021-03-10]
- 百度站长工具取消sitemap索引型sitemap文件提交 [2020-09-24]

