What is 404 error
HTTP 404 error means that the web page pointed to by the link does not exist, that is, the URL of the original web page is invalid. This situation often occurs and is difficult to avoid. For example, changes in web page URL generation rules, changing web page file names or moving locations, misspellings of import links, etc., resulting in the original URL address being inaccessible; when the web server receives a similar request, it will return a 404 status code, telling the browser that the resource to be requested does not exist. However, the default 404 error page of the web server, whether Apache or IIS, is very simple, dull and unfriendly to users. It cannot provide users with the necessary information to obtain more clues, which will undoubtedly cause user churn.
The role of 404 pages
Search engines use HTTP status codes to identify the status of web pages. When a search engine gets an error link, the website should return a 404 status code, telling the search engine to abandon the index of the link. And if the 200 or 302 status code is returned, the search engine will index the link, which results in a large number of different links pointing to the same web content. As a result, search engines have significantly reduced their trust in the website.
How to check that the custom 404 page can return the "404" status code
After the custom 404 error page is set, be sure to check whether it can correctly return the "404" status code. The checking method is also quite simple. Enter the URL that does not exist in a website, check the return status of the HTTP Header, and be sure that it returns a "404" status code.
The correct way to do 404 pages
1. How to set up Apache server 404 page
Add code to the .htaccess file: ErrorDocument 404 /
Create a simple html404 page naming
Just place it in the website root directory.
2. Set 404 error page under IIS/
First, modify the settings of the application root directory, open the "" file editing, and add the following content to it:
<configuration> <> <customErrors mode=”On” defaultRedirect=””> <error statusCode=”404″ redirect=”” /> </customErrors> </> </configuration> |
In this example, "" is the system's default 404 page, and "" is a custom 404 page. Please modify the corresponding file name when using it.
Then, add in the custom 404 page "":
<% = “404 Not Found” %> |
In this way, it is possible to ensure that IIS can correctly return the "404" status code
Friendly reminder
1. Be sure not to turn the 404 error directly to the homepage of the website, as this may cause your homepage to be not included;
2. Please do not include the main domain name before (wrong writing method: /, correct writing method: /), otherwise the returned status code is 302 or 200 status code.