How to implement php jump to 404: first open the corresponding PHP file; then add the code as "@header("http/1.1 404 not found");"; finally output the error page directly through echo. Can jump.
Recommended: "PHP Video Tutorial"
How to implement php jump to 404:
Every website basically has the 404 page. The function of the 404 page is to prevent users from accessing your website. When a page does not exist or is inaccessible, a friendly and clear reply is given to the current user through the 404 page. 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"); //跳转到某一个页面,推荐使用这种方法,注意include文件的路径不能是网络路径 exit();
To check whether the 404 setting is successful, you can use the firebug plug-in of firefox to check. The specific checking method is as follows:
If firebug has been installed Next, use Firefox browser to open the page where you want to check the 404 status code, 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 Various page parameters including headers and responses.
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 How to jump to 404 in php. For more information, please follow other related articles on the PHP Chinese website!