ThinkPHP访问不存在的模块跳到404页面
发布:smiling 来源: PHP粉丝网 添加日期:2014-08-28 14:04:08 浏览: 评论:0
我们来介绍一下关于ThinkPHP访问不存在的模块跳到404页面,有需要的朋友可参考参考,在ACTION中新建一个文件EmptyAction.class.php,文件中的代码如下:
- <?php
- class EmptyAction extends Action{
- //开源代码phpfensi.com
- function _empty(){
- header("HTTP/1.0 404 Not Found");//使HTTP返回404状态码
- $this->display("Public:404");
- }
- }
- ?>
在apache中设置,在你的网站配置中加入 ErrorDocument 404 /404.html 即可.
在iis中设置,IIS/ASP.net下设置404错误页面,打开apache httpd.conf配置文件或者新建.htaccess配置文件.
首先,修改应用程序根目录的设置,打开 “web.config” 文件编辑,在其中加入如下代码:
- <configuration>
- <system.web>
- <customErrors mode=”On” defaultRedirect=”error.asp”>
- <error statusCode=”404″ redirect=”notfound.asp” />
- </customErrors>
- </system.web>
- </configuration>
注:上文例中“error.asp”为系统默认的404页面,“notfound.asp”为自定义的404页面,使用时请修改相应文件名,然后,在自定义的404页面“notfound.asp”中加入如下 代码:
<% Response.Status = “404 Not Found” %>
php 404,代码如下:
- if(如果没有任何结果)
- {
- //以前是仅仅显示“该帖子已经不存在”的提示,现在是:
- require(’/404.php’);
- @header(’HTTP/1.1 404 Not Found’);
- @header(’Status: 404 Not Found’);
- exit;
- }
Tags: ThinkPHP模块 不存在404页面
- 上一篇:thinkphp打开验证码页面是乱码
- 下一篇:ThinkPHP文件上传类的分享
相关文章
- ·解密ThinkPHP3.1.2版本之模块和操作映射(2021-02-26)
- ·ThinkPHP中URL路径访问与模块控制器之间的关系(2021-04-09)

推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)