慕容的工作随笔

慕容的工作随笔

记录学习和工作

ThinkPHP的404页面设定方式

2015-02-14 09:01:00

ThinkPHP中,某一个模块或方法不存在时,自定义404页面的方法

1、在Action目录中新建一个文件名为EmptyAction.class.php的文件

2、代码:

[php] view plaincopyprint?

  1. <?php
  2. class EmptyAction extends Action{
  3.  
  4.     //所请求的模块不存在时,默认执行的模块
  5.     public function index(){
  6.         header("HTTP/1.0 404 Not Found");//404状态码
  7.         $this->display("Common:404"); //显示自定义的404页面模版
  8.     }
  9.  
  10.     function _empty(){
  11.         header("HTTP/1.0 404 Not Found");//404状态码
  12.         $this->display("Common:404");//显示自定义的404页面模版
  13.     }
  14. }
  15. ?>

评论 (0)

还没有评论,来做第一个吧。

发表评论

提交后需管理员审核通过后显示