当我在做搜狗站群程序通过sitemap接接口提交xml地图的时候,我突然想到一种方法:能否通过xml文件中放当前根域名的二级域名的方式来实现快速的二级域名的收录呢?所以便产生了下面的地图文件。
伪静态
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']!=''){ for ($i = 0; $i < 500; $i++) { $host = 'http://'.randchar(5,0).'.'.$arrhost['1'].'.'.$arrhost['2'].'/'; $tmp = $host; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$tmp}</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{ for ($i = 0; $i < 500; $i++) { $host = 'http://'.randchar(5,0).'.'.$arrhost['0'].'.'.$arrhost['1'].'/'; $tmp = $host; $map.= "\t\t<url>\n"; $map.= "\t\t\t<loc>{$tmp}</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; function randchar($length, $type) { $arr = array(1 => "abcdefghijklmnopqrstuvwxyz", 2 => "0123456789", 3 => "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); if($type == 0) { array_pop($arr); $string = implode("", $arr); }elseif($type == "-1") { $string = implode("", $arr); }else{ $string = $arr[$type]; } $count = strlen($string) - 1; for($i = 0; $i < $length; $i++) { $str[$i] = $string[rand(0, $count)]; @$code .= $str[$i]; } return $code; } ?>
本站所有内容仅限用于学习和研究目的,程序仅供本地断网测试,转载请说明出处!
站群SEO » 搜狗站群sitemap:泛二级当前根域名
站群SEO » 搜狗站群sitemap:泛二级当前根域名