ThinkPHP 404页面的设置方法_PHP教程

WBOY
Release: 2016-07-13 10:01:41
Original
773 people have browsed it

ThinkPHP 404页面的设置方法

 这篇文章主要介绍了ThinkPHP 404页面的设置方法,需要的朋友可以参考下

 

 

在很多网站中都会有使用404页面的时候,在ThinkPHP框架中该如何设置呢,接下来我介绍其中一种方法

1、首先要在Lib/Action 下建立EmptyAction.class.php模块
内容如下:

 

 代码如下:


/*
* @author rocky
* @date 20141021
* @desc 空模块404等错误
* */
class EmptyAction extends CommonAction {
function _empty(){
header("HTTP/1.0 404 Not Found");
$this->display('Public:404');
}
}
?>

 

2、做完以上处理,只能在访问到空模块的时候才会访问404页面,所以,为了访问空方法也访问404页面,我们还需要在CommonAction.class.php增加一个空方法了,方法如下:

 

 代码如下:


//处理所有没有的方法的处理方法,引导到404页面
public function _empty() {
R('Empty/_empty');
}

 

3、做完以上工作基本可以了,但是别忘了把你的404.html页面放在Tpl/Public下

这样就ok了,好了,收队收队!~~~

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/971930.htmlTechArticleThinkPHP 404页面的设置方法 这篇文章主要介绍了ThinkPHP 404页面的设置方法,需要的朋友可以参考下 在很多网站中都会有使用404页面的时候,在...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!