Home  >  Article  >  Backend Development  >  生成网站map有什么简易的方法吗

生成网站map有什么简易的方法吗

WBOY
WBOYOriginal
2016-06-13 11:57:541053browse

生成网站地图有什么简易的方法吗?
怎样生成前端使用的网站地图?就是那种表格形式的
我手上有XML文件
------解决方案--------------------
seo的网站地图?
------解决方案--------------------
来看看 增加积分
------解决方案--------------------
如果你使用的建站程序一般带有生成地图功能,可以用自带的,没有的话自己写,按照生成xml格式的要求写程序生成。

具体可以参考如下两篇文章:

1.使用codeIgniter生成网站Sitemap
2.PHP生成sitemap.xml地图文件的代码参考
------解决方案--------------------

<br /><?PHP<br />$content='<?xml version="1.0" encoding="UTF-8"?><br /><urlset<br />    xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"<br />    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9<br />       http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"><br />';<br />$data_array=array(<br />    array(<br />		'loc'=>'http://www.phpernote.com/',<br />		'priority'=>'1.0',<br />		'lastmod'=>'2012-06-03T04:20:32-08:00',<br />		'changefreq'=>'always'<br />    ),<br />    array(<br />		'loc'=>'http://www.phpernote.com/',<br />		'priority'=>'0.5',<br />		'lastmod'=>'2012-06-03T04:20:32-08:00',<br />		'changefreq'=>'daily'<br />    )<br />);<br />foreach($data_array as $data){<br />	$content.=create_item($data);<br />}<br />$content.='</urlset>';<br />$fp=fopen('sitemap.xml','w+');<br />fwrite($fp,$content);<br />fclose($fp);<br /><br />function create_item($data){<br />    $item="<url>\n";<br />    $item.="<loc>".$data['loc']."</loc>\n";<br />    $item.="<priority>".$data['priority']."</priority>\n";<br />    $item.="<lastmod>".$data['lastmod']."</lastmod>\n";<br />	$item.="<changefreq>".$data['changefreq']."</changefreq>\n";<br />    $item.="</url>\n";<br />    return $item;<br />}<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn