muban大师 发表于 2020-2-14 10:51:28

如何隐藏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();
       
          ?>
页: [1]
查看完整版本: 如何隐藏dedecms网站首页网址显示的index.html