Custom error pages returning 200 OK Status
Custom web pages for HTTP404 (page not found) and HTTP500 (internal server error) messages are something we always add to our websites.Recently we tried to add a couple websites to the Google sitemaps programme using verification by file. Google gave to following error: "We've detected that your 404 (file not found) error page returns a status of 200 (OK) in the header".
This is something we never considered, wrongly assuming that IIS would still give the response status of 404 in the header of a custom 404 error page. Surely if webservers and search engines are to work together, custom error pages must still return a 404 status otherwise how will they know when to delete/update pages in their indexes?
Worried that Google and other search engines would be spidering not existent pages on our websites we quickly implement the following solutions:
Initially we thought of adding a status code to the header using IIS itself. See the procedure below.
- Open Internet Information Services (IIS) Manager
- Navigate to the website and find the custom 404 error page
- Right click on the page and select 'Properties'
- Select the 'HTTP Headers' tab
- Click 'Add' to add a custom header
- Add 'HTTP Status Code' to the Custom Header Name
- Add 'HTTP/1.1 404 Not Found' to the Custom header value
A much simpler solution in ASP was to add <%Response.Status = "404 Not Found" %> to the top of the custom error page.
Google sitemaps then worked and our custom 404 error pages were returning a 404 status in the headers.
Published Saturday, May 12, 2007

