Home  >  Article  >  Backend Development  >  PHP defines the implementation code of the 404 page_PHP tutorial

PHP defines the implementation code of the 404 page_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:14:25744browse

Core code:

Copy code The code is as follows:

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

If you need to load the 404 page, you can use the following code, the main thing is to pay attention File path
Copy code The code is as follows:

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

Check whether 404 is set Successfully, you can use the firebug plug-in of firefox to view

Viewing method

When firebug has been installed, use the firefox browser to open the page where you want to check the 404 status code, and click on the bug in the lower right corner icon, 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.

The impact of 404 pages on the website

The impact on SEO is not great. But something is better than nothing. If you have this permission, you'd better set up a 404 page. This thing is the same as the site map. Not all websites need to set it up, but sometimes it is necessary to set it up.
When considering whether to set up a 404 page, you should consider user experience more than SEO.

Let’s take a look at the apache 404 definition
Setting up the 404 error page in apache. The method to set up the 404 error page for the apache server is very simple. Just add the following content to the .htaccess file:
errordocument 404/notfound.php

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326285.htmlTechArticleCore code: Copy the code as follows: @header("http/1.1 404 not found"); @header( "status: 404 not found"); echo 'echo 404'; exit(); If you need to load the 404 page, you can use the following code,...
Statement:
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