当前位置:Gxlcms > PHP教程 > php中header自定义404状态错误页面_PHP教程

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

时间:2021-07-01 10:21:17 帮助过:6人阅读

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.bkjia.comtruehttp://www.bkjia.com/PHPjc/628782.htmlTechArticle404页面就是一个告诉搜索引擎这个页面不存在了,同时也提示用户可以选择其它的操作了,下面我来给没有apache操作权限朋友介绍php中自定...

人气教程排行