ThinkPHP中,某一个模块或方法不存在时,自定义404页面的方法
1、在Action目录中新建一个文件名为EmptyAction.class.php的文件
2、代码:
<?php
class EmptyAction extends Action{
//所请求的模块不存在时,默认执行的模块
public function index(){
header("HTTP/1.0 404 Not Found");//404状态码
$this->display("Common:404"); //显示自定义的404页面模版
}
function _empty(){
header("HTTP/1.0 404 Not Found");//404状态码
$this->display("Common:404");//显示自定义的404页面模版
}
}
?>