为了能在某些XML地图推送泛二级域名时,实现目标域名的主域名的在搜狗收录的目的,特此基于《站群sitemap:地图中仅包含当前域名》升级改造出这个版本的sitemap文件。
伪静态
rewrite ^/(.*).xml$ /sitemap.php?id=$1;
sitemap.php
<?php //error_reporting(0); $arr = explode("/", $_SERVER['REQUEST_URI']); $num = sizeof($arr); header("Content-Type: text/xml"); $map = "\t<urlset>\r\n"; $arrhost = explode(".",$_SERVER['HTTP_HOST']); $date = date("Y-m-d"); if($arrhost['2']!=''){ //根域名+wwww $host = 'http://www.' .$arrhost['1'].'.'.$arrhost['2'].'/'; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$host}</loc>\r\n"; $map.= "\t\t\t<priority>{$date}</priority>\r\n"; $map.= "\t\t\t<lastmod>daily</lastmod>\r\n"; $map.= "\t\t\t<changefreq>0.8</changefreq>\r\n"; $map.= "\t\t</url>\n"; //根域名 $host = 'http://' .$arrhost['1'].'.'.$arrhost['2'].'/'; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$host}</loc>\r\n"; $map.= "\t\t\t<priority>{$date}</priority>\r\n"; $map.= "\t\t\t<lastmod>daily</lastmod>\r\n"; $map.= "\t\t\t<changefreq>0.8</changefreq>\r\n"; $map.= "\t\t</url>\n"; }else{ //根域名+wwww $host = 'http://www.' .$arrhost['0'].'.'.$arrhost['1'].'/'; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$host}</loc>\r\n"; $map.= "\t\t\t<priority>{$date}</priority>\r\n"; $map.= "\t\t\t<lastmod>daily</lastmod>\r\n"; $map.= "\t\t\t<changefreq>0.8</changefreq>\r\n"; $map.= "\t\t</url>\n"; //根域名 $host = 'http://' .$arrhost['0'].'.'.$arrhost['1'].'/'; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$host}</loc>\r\n"; $map.= "\t\t\t<priority>{$date}</priority>\r\n"; $map.= "\t\t\t<lastmod>daily</lastmod>\r\n"; $map.= "\t\t\t<changefreq>0.8</changefreq>\r\n"; $map.= "\t\t</url>\n"; } $map.= "\t</urlset>"; echo $map; die; ?>
本站所有内容仅限用于学习和研究目的,程序仅供本地断网测试,转载请说明出处!
站群SEO » 搜狗站群sitemap:地图中仅包含当前域名升级版
站群SEO » 搜狗站群sitemap:地图中仅包含当前域名升级版