{
    分享网正式开通,我们为大家提供免费资源,欢迎大家踊跃投稿!

打开Sitemap.xml时报“This page contains the following errors:”的解决方法

有一位朋友网站碰到了这么一个问题,准备sitemap.xml提交到百度,用的是google xml sitemap 插件生成,打开xml时报了错误“This page contains the following errors:”,跑来问我怎么解决,我想会不会是插件问题,后来换了Smart SEO tool,问题依旧,换其它浏览器也一样。

后来查了度娘,说是xml文件格式错误,文件头部有空格导致的,于是我把他的sitemap.xml另存到电脑打开,确实是有两行空格:

问题可能出在代码里面,于是找到了Smart SEO Tool里面这段输出XML的代码:

    public static function parse_request($wp){
	    if(!isset($wp->query_vars['wb_sitemap'])){
	        return;
        }


        date_default_timezone_set(get_option('timezone_string'));
        $param = $wp->query_vars['wb_sitemap'];

	    $xml = '';
	    if(empty($param)){
            $xml = self::index();
        }else{
            $xml = self::content($param);
        }
        
        
        header('Content-Type: text/xml; charset=utf-8');
	    echo $xml;
	    exit(0);
    }

很明显是没有清空缓存造成的,加上ob_clean();后问题解决。

 

    public static function parse_request($wp){
	    if(!isset($wp->query_vars['wb_sitemap'])){
	        return;
        }


        date_default_timezone_set(get_option('timezone_string'));
        $param = $wp->query_vars['wb_sitemap'];

	    $xml = '';
	    if(empty($param)){
            $xml = self::index();
        }else{
            $xml = self::content($param);
        }
        
        ob_clean();
        header('Content-Type: text/xml; charset=utf-8');
	    echo $xml;
	    exit(0);
    }

 

 


资源均来自第三方,谨慎下载,前往第三方网站下载


米微资源分享网 , 版权所有丨本站资源仅限于学习研究,严禁从事商业或者非法活动!丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:打开Sitemap.xml时报“This page contains the following errors:”的解决方法
喜欢 ()分享 (0)