時間:2022-07-17 08:57:01 | 來源:建站知識
時間:2022-07-17 08:57:01 來源:建站知識
最近有好些站長朋友反映他們用織夢系統(tǒng)搭建的網(wǎng)站打開網(wǎng)站域名老是跳轉(zhuǎn)到index.html問我有沒有辦法去掉。
要解決這個問題首先我得搞清楚這個問題是怎么引起的,其實這個問題的出現(xiàn)是因為根目錄下面的index.php,我們截取index.php從第14行到38行代碼
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’);
}
這里有一個判斷,網(wǎng)站在不加upcache參數(shù)的情況下(www.dedevvip.com/index.php?upcache=1)和網(wǎng)站根目錄下不存在index.html那么他就直接跳轉(zhuǎn)到index.html
這樣知道問題根源了,那接下來我就給出解決辦法,我們分兩種情況
一、直接動態(tài)瀏覽
網(wǎng)站動態(tài)訪問的情況下,程序會刪除根目錄下面的Index.html ,那么他會執(zhí)行include(dirname(__FILE__)。‘/index.html’);這段代碼,把首頁引用而非跳轉(zhuǎn)。
二、靜態(tài)訪問
關(guān)于這種情況,我們這里分兩種。
1、IIS
打開IIS點擊文檔,里面將index.html置于index.php上面,這有什么作用呢?其實這樣設(shè)置就是在網(wǎng)站同時有index.php和index.html的情況下,先訪問index,html這樣就不會出現(xiàn)跳轉(zhuǎn)的情況
2、Apache
apache里面DirectoryIndex來控制文件檢索優(yōu)先級的
DirectoryIndex index.html index.php index.htm
和iis一樣,我們將index.html往前放
轉(zhuǎn)載請注明來源:
關(guān)鍵詞:
微信公眾號
版權(quán)所有? 億企邦 1997-2022 保留一切法律許可權(quán)利。