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

WBOY
Libérer: 2016-07-13 17:15:36
original
976 Les gens l'ont consulté

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中自定...
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!