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_'));
/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_'));
相关文章推荐
- thinkphp框架下404页面设置 仅三步
- thinkPHP5框架设置404、403等http状态页面的方法
- tp框架的伪静态和真静态页面设置
- thinkphp框架下404页面设置
- thinkphp框架下404页面设置 仅三步
- PHP项目统一设置404页面(包括yii框架下)
- 【Yii2.0.7】在advanced高级模板环境中:设置404自定义页面的方法!
- play框架配置自定义404页面
- thinkphp 404页面设置
- nginx 设置 404 500 页面跳转到指定页面
- TP框架中的页面继承,以及控制器
- 一个使用iframe引入指定页面的指定区域并设置框架透明的例子
- ASP.NET设置404页面返回302HTTP状态码的解决方法
- 404页面设置
- ASP.NET设置404页面返回302HTTP状态码的解决方法
- Thinkphp设置仅在调试模式关闭时显示404页面
- 网站死链接及404页面优化设置
- PHP工作笔记:Yii2框架设置页面的关键词和描述
- thinkphp 设置404页面
- Tomcat 404 错误页面的设置