Server 404 error page http status return value of 200 reason analysis

  

Today, I found a lot of information about the 404 page on the Internet, in order to get some knowledge about 404.

Login the google management tool background and find that the website is not verified, and prompt: We detected that your 404 (file not found) error page returned a 200 (success) status in the header. (When this problem occurs, be sure to pay attention to it)

When using google sitemaps to verify your website, if you use html file verification, you will always encounter such an error (we detected your 404 (not found) The file to error) page returns status code 200 (OK) in the response header, and verification cannot be completed and can only be verified with a meta tag.

This is a problem with the host 404 file configuration, the netizen said so, but I set it on the 404 error page according to the website information, and after the custom 404 error page is set, use the Server Header check Tool, enter a url that does not exist in the web page, check the return status of the HTTP header, returning not "404 Not found", or 200 status code.

No matter how the background management of the server's space provider changes or deletes the custom 404 error page settings, the effect is the same. The http status return value is 200 instead of "404 Not found". Later, I concentrated on the wisdom, and simply deleted the custom 404 error page I wrote, and the server's background custom 404 error setting still retains the link of the 404 error page. Using the Server Header checker, test it and find that the status code returns 404, and it is the system default 404 error page.

The website information is as follows (Note: Most of the first two types of website space servers are not supported, only support .html or htm):

(1) Apache error page is set under Apache

Set the 404 error page for Apache Server is very simple, just add the following content to the .htaccess file: ErrorDocument 404 /notfound.php

Note:

1. Remember Don't redirect 404 errors to the homepage of the website, otherwise it may cause the homepage to disappear in the search engine.

2. Remember not to use absolute URLs. If you use absolute URLs, the status code returned is "302" + "200" ( Tested)

(2) Set 404 error page under IIS/ASP.net

First, modify the settings of the application root directory, open the "web.config" file editor, and add it to it. The following content:








Note: "erro" in the above example R.asp" is the default 404 page of the system, and "notfound.asp" is a custom 404 page. Please modify the file name when using it.

Then, add in the custom 404 page "notfound.asp":

<%

Response.Status = "404 Not Found"

%>

This will ensure that IIS can correctly return the "404" status code

(c) Set 404 static page under IIS/ASP.net

The method of setting a static 404 error page is relatively simple. Right-click the website you want to manage in IIS Manager, open the "Custom Error Information" page in "Properties", and set the corresponding error information page for "404". can. However, here you must select "File" or "Default" in "Message Type" instead of "URL", otherwise it will result in a "200" status code.

Copyright © Windows knowledge All Rights Reserved