How to: Redirect 404 (page not found) pages in PHP and Apache – Internet Explorer problem

Sometimes you want your client to see a different page then the default 404 (page not found)
To do this you just need to add and entry to .htaccess file on your web folder:

ErrorDocument 404 /404err.php

404err.php is an example of the PHP page you want the Apache to serve instead of the apache default.

The problem is that with Internet Explorer this does not work- Internet Explorer gets the 404 header from the apache and shows the user it own 404 default error page.
To solve this issue start the PHP that serves as the error page (404err.php) with this line:

<?php header("HTTP/1.0 200 OK"); ?>

This overwrites the 404 (page not found) with a 200 (everything is great) response and make the Internet Explorer serve your page and not its own 404 default error page

Share the love...Tweet about this on TwitterShare on LinkedInShare on Google+Share on Facebook

Amir Shevat

Amir Shevat is the global Startup Outreach lead in Google Developer Relations ( Previously, Amir Led Google Campus Tel Aviv and was the co founder of several startups.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *