IE and Custom Error Pages
Filed Under: WordPress
An oft overlooked part of one’s website is the 404 page. Many of the visitors who see your 404 page will most likely be first time visitors looking for something in particular. Rather than show them some drab looking “404 Page Not Found” message you might want to consider providing something a little more useful. For instance, my 404 page contains this site’s archives - listed both monthly and topically as well as a short message about what just happened. I also included a few suggestions in addition to my contact info. Your 404 page should be given the same attention as your home page. Consider it the gateway to your site.
The problem is, although all modern browsers will display your custom 404 page, Internet Explorer may not. Since v5, IE insists on using it’s own built-in error page. There are some people who claim that upon arriving at a non-existent URL Internet Explorer will quickly size up your custom error page and if it is less than 512 bytes in total size it will render its own error page. The solution then seems obvious - ensure your custom error page is greater than 512 bytes. Sounds good but it is not foolproof as I found out. As I said earlier, I have plenty of information on my error page and at one point even included a bunch of nonsensical text commented out in the source code which guaranteed the page was greater than 512 bytes yet IE still at times insisted on using its own error page. It was hit and miss.
So how then do we force IE to use your custom error page? Add the following code to the top of 404.php,
<?php ob_start(); ?>
<?php header("HTTP/1.1 404 Not Found"); ?>



No Comments so far. Add Yours Now!
Reply to “IE and Custom Error Pages”
Please note: Comment moderation is in effect. It may take some time for your comment to appear. There is no need to resubmit it.
Off-topic comments, personal attacks, obvious spam and support requests will likely not make it out of moderation. This site does not necessarily endorse or agree with comments left here.