dedecms首页去除index.html

October 30, 2011 | tags dedecms  网站权重  网站优化   | views
Comments 0

在使用dedecms的时候,网站安装完成之后在首页域名中通常会出以index.html为后缀的首页链接地址,其实这也是dedecms需要在网站优化中改进的一点,以www.peryx.cn为例,搜索引擎对http://www.XXXcnhttp://www.XXX.cn/http://www.XXX.cn/index.php http://www.XXX.cn/index.html 这四个URL地址是不同的,在dedecms的根目录下同时存在两个首页文件:index.html和index.php很明显是两个文件,搜索引擎给予的权重也是不同的,网站权重被分散了。下面说一下dedecms首页域名中带index.html如何去掉。
将dedecms自带的index.php文件中的:
<?php
if(!file_exists(dirname(__FILE__).’/data/common.inc.php’))
{
    header(’Location:install/index.php’);
    exit();
}
//自动生成HTML版
if(isset($_GET['upcache']))
{
require_once (dirname(__FILE__) . “/include/common.inc.php”);
require_once DEDEINC.”/arc.partview.class.php”;
$GLOBALS['_arclistEnv'] = ‘index’;
$row = $dsql->GetOne(”Select * From `#@__homepageset`”);
$row['templet'] = MfTemplet($row['templet']);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . “/” . $row['templet']);
$pv->SaveToHtml(dirname(__FILE__).’/index.html’);
include(dirname(__FILE__).’/index.html’);
exit();
}
else
{
header(’HTTP/1.1 301 Moved Permanently’);
header(’Location:index.html’);
}
?>
修改为:
<?php
if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
{
      header('Location:install/index.php');
     exit();
}
require_once (dirname(__FILE__) . "/include/common.inc.php");
require_once DEDEINC."/arc.partview.class.php";
$GLOBALS['_arclistEnv'] = 'index';
$row = $dsql->GetOne("Select * From `dede_homepageset`");
$row['templet'] = MfTemplet($row['templet']);
$pv = new PartView();
$pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
$pv->Display();
?>

此时再访问首页的时候就不会出现上述的问题了。

 

文章转载注明:思静石网络营销博客
文章地址:http://www.peryx.cn/wangzhanyouhua/dedecms-index.html




发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。