Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-05-25 16:48:14
Original
1475 people have browsed it

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

实例代码如下:

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

加载一个404错误页面

实例代码如下:

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

也可以在站点中加入.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
Copy after login

修改为

实例代码如下:

ErrorDocument 404 /404.htm
Copy after login

   


永久地址:

转载随意~请带上教程地址吧^^

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 Recommendations
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!