Home  >  Article  >  php教程  >  在thinkphp框架中添加404页面的方法

在thinkphp框架中添加404页面的方法

WBOY
WBOYOriginal
2016-06-07 11:44:281114browse

在thinkphp框架中添加404页面的方法
第一步:

在Lib/Action文件夹下创建EmptyAction.class.PHP<?php <br /> class EmptyAction extends Action{<br>     function _empty(){<br>         header("HTTP/1.0 404 Not Found");//使HTTP返回404状态码<br>         $this->display("Public:404");<br>     }<br>     <br>     function index() {<br>         header("HTTP/1.0 404 Not Found");<br>         $this->display('Public:404');<br>     }<br> }<br> ?>第二步:

修改Lib/Action文件夹下所有的Action文件,在所有的控制器文件中加入如下代码:function _empty(){<br>     header("HTTP/1.0 404 Not Found");//使HTTP返回404状态码<br>     $this->display("Public:404");<br> }第三步,

在Tpl/Public文件夹下创建404页面404.html

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn