Archive for the 'Tips 4 Geeks' category
This is a nice tip for people having problems with custom 404 pages in Internet Explorer. If you don’t know what a 404 error is, then let me explain in the shortest form possible:
It’s what your browser gets when it can’t find the page you requested.
There, a very low-tech explanation that goes straight to the point. If you want a “real” explanation, I suggest www.plinko.net.
Take a look around - they have everything you need to know about 404, and then some.
When I was making my very own custom 404 page for this blog, which should be a reasonably easy task, I stumbled upon a really weird problem. No matter how much I tried, I could not see the page in Internet Explorer. It was working fine in Firefox, but IE kept showing me its own standard “Page not found”. I went googling on the problem and it became clear that this is a known issue. IE is a little bit too smart for its own good – if you dig through the options, you’ll find a little gem named “Show friendly HTTP error messages”. If this is enabled, then IE can choose to ignore the content of error pages and show its own version of them. And, this option is enabled by default (of course…).
A good workaround is to prevent your browser from knowing that your page is actually a 404 page, and you can do that by forcing the return of a code 200.
How exactly you do that? Well depends on which technology you are using for generating the pages. Basically, you must be able to control the HTTP headers being returned. In the case of PHP (which I use in this case), I could solve my problem by adding this block of code:
<?php
header("HTTP/1.1 200 OK");
header("Status: 200 OK");
?>
The two different styles of declarations are just to ensure that will work, regardless of what version of PHP is being used. Note that this must absolutely be the first thing on the page!
You can check my 404 page. If I did my job right, you should see it, even in IE.
Categories: Tips 4 Geeks
1 Comment »