Internet Explorer's
|
See this reference for information about other return codes sent to the browser from the server. |
In the header information of the above document is a status code that tells the browser that this was a file generated as a result of a 'file not found' error. The header status information looks something like this for this error: Status: HTTP/1.0 404 NOT FOUND |
Header information does not show in the browser window, this is information passed between browser and server that is not visible to the user. |
Webmasters can setup their own error handling documents so that a more descriptive page or a redirect to an active page can be sent to tbe browser instead of the above bland one. These pages are set up (on an Apache server) by editting the .htaccess file and adding an ErrorDocument directive: ErrorDocument 404 /nofile.htm The above directive, when placed in the .htaccess file, instructs the server to send the document called nofile.htm (in the root directory in this case) whenever a browser requests a file that does not exist (ie. generates a 404 error). This makes for a much smoother, user-friendly way to gently nudge site visitors from an old, outdated, and missing page to one that is active and designed to help people find their way. In the header information of this file, although, is still the above Status indication that the document was a result of a 404 error. |
|
The IE5 problemBecause many, many webmasters neglect to implement user-friendly error handling, one still sees a lot of the above bland 404 error pages. Microsoft wanted to give Internet Explorer users an option to get a 'friendlier' page instead of a bland one. When IE5 gets a document that has a header status of 404 it will provide its own page. This is slightly better than the above bland page, but the problem is that it also traps the pages that webmasters have carefully developed to help their visitors. It is an option that IE users can turn off, but it is turned on by default and not many people turn it off. |
To turn on/off this option: |
A fixOne way for a webmaster to insure IE will not interfere with his error handling is to make sure the header of his error document does not contain the the 404 status. A way to do this is to generate the status information in the header yourself rather than having the server do it. A very easy way if your web server supports PHP is to add the following to the very beginning of your error document: <? header("Status: HTTP/1.0 200 OK"); ?> This give the normal successful status response code to the browser so it believes that it is just a normal document with no problems. If your original error document was called not_found.htm (for example) and your .htaccess therefore contained: ErrorDocument 404 /not_found.htm rename not_found.htm to not_found.phtml (or not_found.php, ask you server admin if you are not sure) and change your .htaccess to point to it with: ErrorDocument 404 /not_found.phtml and add the PHP to the HTML code at the very beginning like this: <? header("Status: HTTP/1.0 200 OK"); ?> <html> <head> <title>File not found</title> remaining HMTL here... etc... If you'd rather do it in PERL you could create a file called not_found.cgi (for example) and place it in you executable directory (cgi-bin, for example) as follows: #!/usr/bin/perl print "Status: HTTP/1.0 200 OK\n"; print "Content-type: text/html\n\n"; print <<endOfDoc <html> <head> <title>File not found</title> remaining HTML here... etc... endOfDoc And then set your ErrorDocument directive in .htaccess to point to it by: ErrorDocument 404 /cgi-bin/not_found.cgi Another wayAnother fix that appears to work is to have the ErrorDocument call a file that simply redirects to another file. This causes the header status also to be normal and IE doesn't interfere: For example in PHP, the file pointed to in the ErrorDocument directive (as above, not_found.phtml) is just the one line below and the actual error document is in the file new_not_found.htm: <? header("Location: new_not_found.htm"); ?> or in PERL the ErrorDocument (as above, not_found.cgi) would be the following: #!/usr/bin/perl print "Location: new_not_found.htm\n\n"; Both the above PHP and PERL examples simply redirect to another file but by doing so the server sends out a normal status code and IE will not inject its own document. I believe the above examples all work, I have set up the ErrorDocument directive at vogelnet.com with the first (PHP) example so feel free to test it with http://vogelnet.com/some_random_chars.htm. If it doesn't work as advertised above, please let me know. For the test, make sure that terrible option is checked so that you will see IE "friendly HTTP error pages" if it doesn't work (see above on the right). After you are done testing (in my humble opinion) turn off and leave off that option. Update: I recently found a reference that suggests that if the error document is larger than 512 bytes, IE will not inject its own page (apparently assuming that the webmaster has provide a friendly error page already). It did seem to work with a page with a lot of text, but did not seem to work with a page that was made at least that large by the inclusion of an image. |