Home > Backend Development > PHP Problem > 404 error when php jumps

404 error when php jumps

藏色散人
Release: 2023-02-24 11:08:01
Original
3331 people have browsed it

404 error when php jumps

404 error when php jumps

How to write php header 404 jump error page

Every website basically has the 404 page. The role of the 404 page is when the user accesses a non-existent page or an inaccessible page in your website. At this time, the 404 page is used. Give the current user a friendly and clear reply. Tell him that the address does not exist and tell him what to do next.

In PHP programs, we often need to consider how to use PHP to write 404 page jumps. The author below will share with you how to use PHP to write 404 redirects!

@header("http/1.1 404 not found"); 
@header("status: 404 not found"); 
echo 'echo 404';//直接输出页面错误信息 
exit();
Copy after login

Or:

@header("http/1.1 404 not found"); 
@header("status: 404 not found"); 
include("http://www.phpernote.com/404.html");//跳转到某一个页面,推荐使用这种方法 
exit();
Copy after login

To check whether 404 is set successfully, you can use the firebug plug-in of firefox to check. The specific checking method is as follows:

When firebug has been installed, use Open the page where you want to check the 404 status code in Firefox browser, click the bug icon in the lower right corner, start the "Network" tab, and open "Network-All/html-headers" in order; if everything is normal, you can see headers, Response to various page parameters including.

In addition, here is the definition of the apache 404 error page. The specific definition method is as follows:

Create a new .htaccess file in the root directory of the website, and then Just add the following content to the file:

ErrorDocument 404 http://www.phpernote.com/404.html
Copy after login

The above is the detailed content of 404 error when php jumps. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template