首页 > CMS建站 > 织梦DEDE > 正文

隐藏dedecms网站首页网址显示的index.html

2020-07-02 22:19:22
字体:
来源:转载
供稿:网友
这篇文章主要为大家详细介绍了隐藏dedecms网站首页网址显示的index.html,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,有需要的朋友可以收藏方便以后借鉴。

        有的Dedecms织梦默认生成首页后,首页的链接后面会多出一个index.html,官方说法这样有利于网站优化。出于不让首页权重分散考虑,同时也是美观考虑,dede首页的index.html还是得去掉好。

  下面就给大家分享一下如何去掉织梦首页的index.html

  方法一:

  使用.htaccess文件目前使用的是这个办法,试验成功。

  方法如下:

  在根目录的.htaccess里加入以下代码:

  DirectoryIndex index.html index.php index.htm

  方法二:

  在主机里面设置默认首页顺序:把index.html提到最前面。

  因主机不同,设置方法也不同,大多数空间都是在空间商会员后台可以改动。例如:万网。

  方法三:也是最简单行之有效的办法。

  找到根目录下的index.php文件,找到如下内容

  //自动生成HTML版  if(isset($_GET['upcache']) || !file_exists('index.html'))  {  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']);  $row['showmod'] = isset($row['showmod'])? $row['showmod'] : 0;  if ($row['showmod'] == 1)  {  $pv->SaveToHtml(dirname(__FILE__).'/index.html');  include(dirname(__FILE__).'/index.html');  exit();  } else {  $pv->Display();  exit();  }  }  else  {  header('HTTP/1.1 301 Moved Permanently');  header('Location:index.html');  }  ?>

  把上面一大段替换成下面的这段代码

  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();  ?>

完成。

以上就是隐藏dedecms网站首页网址显示的index.html的全部内容,希望对大家的学习和解决疑问有所帮助,也希望大家多多支持错新网。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表