Custom Errors in Apache
I came across this in the httpd.conf on the apache web servers for a major web site of ours. The initial configuration had been hosted at a third party facility, then was brought in-house when the parent company purchased the firm that initially developed the web site. Below is an example of the custom error page handler from this site:
ErrorDocument 404 /custom_errors/404.html RewriteRule /custom_errors /webapp/path/404.html [R]
The first line sets the 404 custom error page to a page running on the local server. The rewrite rule then issues a 302 redirect to the browser and tells the browser to pull the page from the web application path, (even though the page actually exists on the local filesystem as /custom_errors/404.html). The only reason why I can think that the developer wanted this done was so that the page appears to be getting delivered from the same web application path that everything else was delivered from.
The main problem though with this kind of approach to custom error page handling is that you lose the 404 response code. If ErrorDocument is set to 404 with a custom error page, apache still responds with a 404 - Not Found message but if you then issue a rewrite, then your browser receives a 302 redirect followed by a custom error page delivered with a 200 OK status. This ultimately means that your custom error pages can get listed in search engines results pages (SERP).
We had one of these for 503 status codes too and it sure was interesting searching on Google for "
name of the site +service interruption" and seeing how many valid links wound up getting listed with the "We're sorry. We are experiencing a service interruption" description.
The thing to keep in mind for web site administrators is that just because developers know ASP or JSP or whatever really well, it does not mean that they necessarily understand how the web and browsers work. If you see a custom 404 errors implemented as a jsp page, make sure that at the top of the source of that jsp page you see something like:
<html> <head> <title>404 - Not Found</title> <% response.setStatus(404); %> </head> <body> </body> </html>
If it isn't there, get someone to put it there. Otherwise, your business partners might wind up asking you why they are seeing the site's custom error pages showing up in Google's search engine result pges.