仲介交易 HTTP://www.aliyun.com/zixun/aggregation/6858.html">SEO診斷 淘寶客 雲主機 技術大廳
最近有好些站長朋友反映他們用織夢系統搭建的網站打開網站功能變數名稱老是跳轉到index.html問我有沒有辦法去掉。
要解決這個問題首先我得搞清楚這個問題是怎麼引起的,其實這個問題的出現是因為根目錄下面的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’);
}
這裡有一個判斷,網站在不加upcache參數的情況下(www.dedevvip.com/index.php?upcache=1)和網站根目錄下不存在index.html那麼他就直接跳轉到index.html
這樣知道問題根源了,那接下來我就給出解決辦法,我們分兩種情況
一、直接動態流覽
網站動態訪問的情況下,程式會刪除根目錄下面的Index.html ,那麼他會執行include(dirname(__FILE__)。 ‘/index.html’);這段代碼,把首頁引用而非跳轉。
二、靜態訪問
關於這種情況,我們這裡分兩種。
1、IIS
打開IIS點擊文檔,裡面將index.html置於index.php上面,這有什麼作用呢?其實這樣設置就是在網站同時有index.php和index.html的情況下,先訪問index,html這樣就不會出現跳轉的情況
2、Apache
apache裡面DirectoryIndex來控制檔檢索優先順序的
DirectoryIndex index.html index.php index.htm
和iis一樣,我們將index.html往前放
轉載請注明來源:HTTP://www.dedevvip.com/question/11.html