ThinkPHP訪問不存在的模組跳到404頁面_PHP教程

來源:互聯網
上載者:User
我們來介紹一下關於ThinkPHP訪問不存在的模組跳到404頁面 有需要的朋友可參考參考。

在ACTION中建立一個檔案EmptyAction.class.php,檔案中的代碼如下:

代碼如下 複製代碼

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

在apache中設定

在你的網站配置中加入 ErrorDocument 404 /404.html 即可。


在iis中設定

IIS/ASP.net下設定404錯誤頁面

開啟apache httpd.conf設定檔或者建立.htaccess設定檔


首先,修改應用程式根目錄的設定,開啟 “web.config” 檔案編輯,在其中加入如下內容:

代碼如下 複製代碼







註:上文例中“error.asp”為系統預設的404頁面,“notfound.asp”為自訂的404頁面,使用時請修改相應檔案名稱。
然後,在自訂的404頁面“notfound.asp”中加入:

代碼如下 複製代碼

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


php 404

代碼如下 複製代碼

if(如果沒有任何結果)
{
//以前是僅僅顯示“該文章已經不存在”的提示,現在是:
require(’/404.php’);
@header(’HTTP/1.1 404 Not Found’);
@header(’Status: 404 Not Found’);
exit;
}


http://www.bkjia.com/PHPjc/444652.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444652.htmlTechArticle我們來介紹一下關於ThinkPHP訪問不存在的模組跳到404頁面 有需要的朋友可參考參考。 在ACTION中建立一個檔案EmptyAction.class.php,檔案中的代碼...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.