Home > Article > Backend Development > 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();
Or:
@header("http/1.1 404 not found"); @header("status: 404 not found"); include("http://www.phpernote.com/404.html");//跳转到某一个页面,推荐使用这种方法 exit();
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
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!