What is Error 404?
An HTTP 404 error means that the webpage to which the link points does not exist, that is, the URL of the original webpage is invalid. This situation often occurs and is difficult to avoid. For example: the original URL address cannot be accessed because the webpage URL generation rules are changed, the webpage file is renamed or moved, and the import link is misspelled. When the Web server receives a similar request, A 404 status code is returned to tell the browser that the requested resource does not exist. However, no matter Apache or IIS, the default 404 error page of the Web server is very simple, dull, and unfriendly to users, and cannot provide users with the necessary information to obtain more clues, this will undoubtedly lead to the loss of users.
404 page Functions
The search engine uses HTTP status codes to identify the status of webpages. When the search engine gets an error link, the website should return a 404 status code, telling the search engine to discard the index of the link. If a 200 or 302 status code is returned, the search engine creates an index for the link, which leads to a large number of different links pointing to the same webpage content. As a result, the search engine significantly reduced its trust in the website.
How to check whether the custom 404 page can return the "404" status code
After setting the custom 404 error page, make sure that the "404" status code is returned correctly. The check method is also quite simple. Enter a url without a webpage in the website, check the HTTP Header returned, and make sure it returns the "404" status code.
404 correct page practices
1. How to set the 404 page of Apache server
Add code to the. htaccess file: ErrorDocument 404/Error.html
Create a simple html404 page named Error.html
Place Error.html in the root directory of the website.
2. Set the 404 error page in IIS/ASP.net
First, modify the application root directory settings, open the "web. config" file, and add the following content to it:
<Configuration> <System. web> <CustomErrors mode = "On" defaultRedirect = "error. asp"> <Error statusCode = "404" redirect = "notfound. asp"/> </CustomErrors> </System. web> </Configuration> |
In this example, "error. asp" is the default 404 page, and "notfound. asp" is the custom 404 page. Modify the file name when using it.
Then, add the following content to the custom 404 page "notfound. asp:
<% Response. Status = "404 Not Found" %> |
In this way, you can ensure that IIS returns the "404" status code correctly.
Reminder
1. Do not direct the 404 error to the website homepage, which may cause your website homepage not to be indexed;
2. do not include the primary domain name before/Error.html (incorrect syntax: yzznl.cn/error.html, and Error.html). Otherwise, the returned status code is 302 or 200.