ecshop站点地图sitemap.xml生成后其实是有错误的,而且错的很严重,特别是新手想优化网站,按照网上教程做了站点地图,最后乱套了。在百度等搜索引擎支持情况下,错的严重,当然收录不好了。 ecshop模板堂这里说明三点修改,都是以后台admin/sitemap.php文件为例
1.把ecshop站点地图sitemap.xml生成改成绝对路径。
找到43到48行
$domain = $ecs->url();
$today = local_date('Y-m-d');
$sm =& new google_sitemap();
$smi =& new google_sitemap_item($domain, $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']);
$sm->add_item($smi);
修改成
$domain = '';
$today = local_date('Y-m-d');
$sm =& new google_sitemap();
$smi =& new google_sitemap_item('//www.zuimoban.com/', $today, $_POST['homepage_changefreq'], $_POST['homepage_priority']);
$sm->add_item($smi);
好处是,做了自定义URL,改了绝对路径后,地图生成网址也是对的
2. 把ecshop站点地图sitemap.xml生成的文章附件URL网址去除
找到95到105行
/* 文章 */
$sql = "SELECT article_id,title,file_url,open_type FROM " .$ecs->table('article'). " WHERE is_open=1";
$res = $db->query($sql);
while ($row = $db->fetchRow($res))
{
$article_url=$row['open_type'] != 1 ? build_uri('article', array('aid'=>$row['article_id']), $row['title']) : trim($row['file_url']);
$smi =& new google_sitemap_item($domain . $article_url,
$today, $_POST['content_changefreq'], $_POST['content_priority']);
$sm->add_item($smi);
}
修改成
/* 文章 */
$sql = "SELECT article_id,title,file_url,open_type FROM " .$ecs->table('article'). " WHERE is_open=1";
$res = $db->query($sql);
while ($row = $db->fetchRow($res))
{
$smi =& new google_sitemap_item($domain . build_uri('article', array('aid' => $row['article_id']), $row['title']),
$today, $_POST['content_changefreq'], $_POST['content_priority']);
$sm->add_item($smi);
}