您的位置:首页 > 编程语言 > PHP开发

TP框架3.2.3设置404页面

2017-12-25 10:06 483 查看
无法加载模板跳向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_'));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: