火端搜索v2.1自行二开加入xml伪静态,根据词库包生成xml,说干就干
else if(preg_match("/sitemap\/(.+?).html/", $rewrite, $match)){ $_GET['name']=$match[1]; include('inc/sitemap.PHP'); exit; }
else if(preg_match("/sitemap\/(.+?).xml/", $rewrite, $match)){ $type=='.xml'; $_GET['name']=$match[1]; include('inc/sitemapxml.PHP'); exit; }
然后在/inc/下目录新建sitemapxml.PHP文件,如:
<?PHP if(isset($_GET['name'])){ $key = $_GET['name']; $type='.xml'; $dirname = ROOT_PATH.'/data/sitemap/'; $file = $dirname.$key.'.txt'; if(!is_file($file)){ $file = $dirname.iconv("utf-8","gb2312",urldecode($key)).'.txt'; } if($type=='.xml'){ header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="utf-8"?>'; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'; if(is_file($file)){ $worddata = file_get_contents($file); if(strpos($worddata,"\r\n")>-1){ $words = explode("\r\n",$worddata); }else{ $words = explode("\n",$worddata); } foreach($words as $k=>$v){ if(strlen($v)>1){ echo '<url><loc>'.huoduansourl($v).'</loc></url>'."\r\n"; } } }else{ echo 'Sitemap相关文件不存在'; } echo '</urlset>'; }else{ if(is_file($file)){ $worddata = file_get_contents($file); if(strpos($worddata,"\r\n")>-1){ $words = explode("\r\n",$worddata); }else{ $words = explode("\n",$worddata); } foreach($words as $k=>$v){ if(strlen($v)>1){ echo huoduansourl($v)."\r\n"; } } }else{ echo 'Sitemap相关文件不存在'; } } exit; } if(isset($_GET['name'])){ $name = htmlspecialchars($_GET['name']); if(substr($name,0,1)=='.' || substr($name,0,1)=='/'){ echo 'Name参数不合法';exit; } $nametitle = $name.'相关词'; } if(isset($_GET['p'])){ $p=htmlspecialchars($_GET['p']); }else{ $p=1; } ?>
这样就完美了,演示地图:http://www.myjiancai.net/so/sitemap/fangzhukou.html 而他的地图版本是:http://www.myjiancai.net/so/sitemap/fangzhukou.xml
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。