Ⅰ 大神們 thinkphp怎麼設置404頁面 謝謝
在ACTION中新建一個文件EmptyAction.class.php,文件中的代碼如下:
<?php
classEmptyActionextendsAction{
function_empty(){
header("HTTP/1.0404NotFound");//使HTTP返回404狀態碼
$this->display("Public:404");
}
}
?>
在apache中設置
在你的網站配置中加入ErrorDocument404/404.html即可。
在iis中設置
IIS/ASP.net下設置404錯誤頁面
打開apachehttpd.conf配置文件或者新建.htaccess配置文件
首先,修改應用程序根目錄的設置,打開「web.config」文件編輯,在其中加入如下內容:
<configuration>
<system.web>
<customErrorsmode=」On」defaultRedirect=」error.asp」>
<errorstatusCode=」404″redirect=」notfound.asp」/>
</customErrors>
</system.web>
</configuration>
註:上文例中「error.asp」為系統默認的404頁面,「notfound.asp」為自定義的404頁面,使用時請修改相應文件名。
然後,在自定義的404頁面「notfound.asp」中加入:
<%
Response.Status=「404NotFound」
%>
php404
if(如果沒有任何結果)
{
//以前是僅僅顯示「該帖子已經不存在」的提示,現在是:
require(』/404.php』);
@header(』HTTP/1.1404NotFound』);
@header(』Status:404NotFound』);
exit;
}