欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ThinkPHP訪問不存在的模塊跳轉到404頁面的方法

 更新時間:2014年06月19日 17:03:59   投稿:shichen2014  
這篇文章主要介紹了ThinkPHP訪問不存在的模塊跳轉到404頁面的方法,需要的朋友可以參考下

首先在ACTION中新建一個文件EmptyAction.class.php,其代碼如下:

<?php 
 class EmptyAction extends Action{ 
 function _empty(){ 
  header("HTTP/1.0 404 Not Found");//使HTTP返回404狀態(tài)碼 
  $this->display("Public:404"); 
 } 
 } 
 ?>

使用apache服務器的情況下需在apache中的網(wǎng)站配置中加入 ErrorDocument 404 /404.html 即可。

使用iis服務器的情況下需在iis中的IIS/ASP.net下設置404錯誤頁面。

打開apache httpd.conf配置文件或者新建.htaccess配置文件

首先,修改應用程序根目錄的設置,打開 “web.config” 文件編輯,在其中加入如下內容:

<configuration>
 <system.web>
 <customErrors mode=”O(jiān)n” defaultRedirect=”error.asp”>
 <error statusCode=”404″ redirect=”notfound.asp” />
 </customErrors>
 </system.web>
 </configuration>

注:上文例中“error.asp”為系統(tǒng)默認的404頁面,“notfound.asp”為自定義的404頁面,使用時請修改相應文件名。
然后,在自定義的404頁面“notfound.asp”中加入:

<%
 Response.Status = “404 Not Found”
 %>
 

php的404頁面:

 if(//如果沒有任何結果)
   {
   //以前是僅僅顯示“該帖子已經(jīng)不存在”的提示,現(xiàn)在是:
   require('/404.php');
   @header('HTTP/1.1 404 Not Found'');
   @header('Status: 404 Not Found');
   exit;
   }
 

相關文章

最新評論