TP框架3.2.3設置404頁面

無法加載模板跳向404頁面
/thinkphp/library/think/Dispatcher.class.php中176行
    // 加載模塊的擴展配置文件
            load_ext_file(MODULE_PATH);
        }else{
            header("Location:/404.html");die;
            // E(L('_MODULE_NOT_EXIST_').':'.MODULE_NAME);
        }
加上header跳轉頁面,404.html放在跟下


無法加載控制器跳向404頁面
創建一個EmptyController.class.php 代碼如下 
<?php
namespace Home\Controller;
use Think\Controller;
class EmptyController extends Controller
{
public function _empty(){
        $this->display('Error/404');//在Home/view中Error文件夾中
    }
}
這樣就行
無法加載方法跳向404頁面
在/thinkphp/library/think/Controller.class.php在170行加上重跳轉404頁面
 public function __call($method,$args) {
        if( 0 === strcasecmp($method,ACTION_NAME.C('ACTION_SUFFIX'))) {
            if(method_exists($this,'_empty')) {
                // 如果定義了_empty操作 則調用
                $this->_empty($method,$args);
            }elseif(file_exists_case($this->view->parseTemplate())){
                // 檢查是否存在默認模版 如果有直接輸出模版
                $this->display();
            }else{
                $this->display('Error/404');
                // E(L('_ERROR_ACTION_').':'.ACTION_NAME);
            }
        }else{


            E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_'));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章