ThinkPHP3.2如何設定404跳轉頁面
阿新 • • 發佈:2019-01-09
ThinkPHP中,某一個模組或方法不存在時,自定義404頁面的方法
1、在Action目錄中新建一個檔名為EmptyAction.class.php的檔案
2、程式碼:
[php] view plaincopyprint?- <?php
- class EmptyAction extends Action{
- //所請求的模組不存在時,預設執行的模組
- publicfunction index(){
- header("HTTP/1.0 404 Not Found");//404狀態碼
-
$this->display("Common:404"
- }
- function _empty(){
- header("HTTP/1.0 404 Not Found");//404狀態碼
- $this->display("Common:404");//顯示自定義的404頁面模版
- }
- }
- ?>
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
-------------中插入***-----------
echo 'xxxx';
}
}