PHP头条
热点:

php中header自定义404状态错误页面


404页面就是一个告诉搜索引擎这个页面不存在了,同时也提示用户可以选择其它的操作了,下面我来给没有apache操作权限朋友介绍php中自定义404页面的操作方法。

方法一

 代码如下 复制代码

@header("http/1.1 404 not found");
@header("status: 404 not found");
echo 'echo 404';
exit();

加载一个404错误页面

 代码如下 复制代码


@header("http/1.1 404 not found");
@header("status: 404 not found");
include("../../404.htm");
exit();


也可以在站点中加入.htaccess 代码如下

 代码如下 复制代码

errordocument 404 /404.html

如果有apahce配置权限,我们可以修改 httpd.conf

找到:

 代码如下 复制代码
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 xxxxxxx


修改为

 代码如下 复制代码
ErrorDocument 404 /404.htm

www.phpzy.comtrue/php/452.htmlTechArticlephp中header自定义404状态错误页面 404页面就是一个告诉搜索引擎这个页面不存在了,同时也提示用户可以选择其它的操作了,下面我来给没有apache操作权限朋友介绍php中自定义404页面的操...

相关文章

相关频道:

PHP之友评论

今天推荐