如何去掉DEDE首頁index.html
2024-04-25 20:48:15
供稿:網友
dede織夢系統按照默認的設置安裝后,訪問首頁時候,域名后面總跟隨著一個/index.html的后綴,從SEO方面來說,這樣很不好,比如你的連接都是www.49028c.com,而訪問這個域名時候,實際上打開的頁面總是www.49028c.com/index.html,這樣你的網站權重就分散了。
DEDE如何去掉首頁index.html?這樣做有什么用,為什么要去掉啊?
答案就是這樣做的效果就是域名url做的更短,這樣對我們網站的優化是非常有好處的,那么我們該怎么做呢?
首先,我想強調的一點就是有的空間可能默認顯示的就是沒帶index.html,那么下面的內容你可以忽略掉了。
我們有兩種方法可以實現:
第一種: 就是在你的空間控制面板中,將index.html默認首頁的優先級設為最高。一般的空間都會提供這種功能,這也是最好的,如果萬一,不能怎么辦呢?別慌有下面的一種方法即可:
第二種:我們找到dede根目錄下的index.php文件:代碼如下:
在www/ dede自帶的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 `dede_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();
?>
試試吧。是不是已經搞定了!