织梦dedecms去掉网站首页链接后边的index.html

织梦建站教程评论3.9K4阅读模式

有时候织梦dedecms网站默认生成首页后,首页的链接后面会多出一个index.html,这个index.html怎么看都不舒服,而且也不利于seo中主页url的统一,所以出于不让首页权重分散考虑,同时也是美观考虑,织梦dedecms网站首页的index.html还是得去掉好,解决首页域名跳转到/index.html问题。

织梦dedecms首页去掉index.html的几种方法:

1、在空间面板里面找到默认首页设置

把index.html提到最前面

2、修改网站根目录下的index.php文件

如果你在服务器上已经设置了默认文档,依然显示index.html的话,可以用下面的方法解决:

找到网站根目录下的index.php文件

  1. header('HTTP/1.1 301 Moved Permanently');
  2. header('Location:index.html');

把上面这两行换成:

  1. include(dirname(__FILE__).'/index.html');
  2. exit();

注:还不成功,一般是因为浏览器没有清空缓存。

3.使用.htaccess文件

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

方法如下:

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

  1. DirectoryIndex index.html index.php index.htm

就这么简单。

4、按官方给的更新说明 替换index.php的内容 生成动态,

如果首页不需要生成HTML的, 把index.php换成下面代码,当然如果要生成html就不行了。

  1. <?php
  2. if(!file_exists(dirname(__FILE__).'/data/common.inc.php'))
  3. {
  4. header('Location:install/index.php');
  5. exit();
  6. }
  7. require_once (dirname(__FILE__) . "/include/common.inc.php");
  8. require_once DEDEINC."/arc.partview.class.php";
  9. $GLOBALS['_arclistEnv'] = 'index';
  10. $row = $dsql->GetOne("Select * From `dede_homepageset`");
  11. $row['templet'] = MfTemplet($row['templet']);
  12. $pv = new PartView();
  13. $pv->SetTemplet($cfg_basedir . $cfg_templets_dir . "/" . $row['templet']);
  14. $pv->Display();
  15. ?>

SEO优化问题咨询
评论  0  访客  0

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定