1、做网站seo网站地图也是帮助网站收录的方法之一
下载sitemap-php类 自动生成的xml、html文件,帮助Google、Bing、Baidu等主流搜索引擎收录。
2、地图示例 sitemap
米扑代理 sitemap.xml : http://proxy.mimvp.com/sitemap.xml
米扑代理 sitemap.html : XML Sitemap
3、示例代码
#初始化类对象
$sitemap = new Sitemap("http://mimvp.com");
#添加Item
$sitemap->addItem('/', '1.0', 'daily', 'Today');
$sitemap->addItem('/hr.php', '0.8', 'monthly', time());
$sitemap->addItem('/index.php', '1.0', 'daily', 'Jun 25');
$sitemap->addItem('/about.php', '0.8', 'monthly', '2017-06-26');
#或者
$sitemap->addItem('/hr2.php', '1.0', 'daily', time())->addItem('/index2.php', '1.0', 'daily', 'Today')->addItem('/about2.php', '0.8', 'monthly', 'Jun 25');
# 结束文档
$sitemap->endSitemap();#结果如下
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://mimvp.com/</loc>
<priority>1.0</priority>
<changefreq>daily</changefreq>
<lastmod>2017-06-26T00:00:00+08:00</lastmod>
</url>
<url>
<loc>http://mimvp.com/hr.php</loc>
<priority>0.8</priority>
<changefreq>monthly</changefreq>
<lastmod>2017-06-26T20:16:23+08:00</lastmod>
</url>
<url>
<loc>http://mimvp.com/index.php</loc>
<priority>1.0</priority>
<changefreq>daily</changefreq>
<lastmod>2017-06-25T00:00:00+08:00</lastmod>
</url>
<url>
<loc>http://mimvp.com/about.php</loc>
<priority>0.8</priority>
<changefreq>monthly</changefreq>
<lastmod>2017-06-26T00:00:00+08:00</lastmod>
</url>
</urlset>
5、更多操作
#设置根域名
$sitemap = new Sitemap("http://mimvp.com");
#也可以修改初始化的域名为 $sitemap->setDomain('http://blog.mimvp.com');
#设置保存路径 sitemap.xml默认保存在当前目录下,也可设置文件夹目录,例如: xmls/sitemap,表示sitemap.xml保存在当前目录下的xmls/目录下,其中xmls目录会自动创建。注:支持多级目录
$sitemap->setXmlFile("xmls/sitemap");
$sitemap->setXmlFile("xmls/mimvp/sitemap");#设置是否更多头部
$sitemap->setIsChemaMore(true);
#如果设置为true,则sitemap.xml文件头部会增加一些头部信息: xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"#获取当前写入的sitemap文件
$sitemap->getCurrXmlFileFullPath();
谢谢大家点赞支持