Welcome to WebmasterWorld Guest from 22.214.171.124
In apache you should have something like -
ErrorDocument 404 /some_dir/my_error_page.php
So that when you go to example.com/doesnt_exist/bla_bla.not
apache redirects that request through to /some_dir/my_error_page.php
You may find that if you have used the full address for the apache ErrorDocument then you will get a 302 status, as http//something (: removed so there isnt a link...is there any way to stop that?) will result in an external redirect and a 302 header, then it gets to that page and has a 404 header thrown at it. Would be very confusing.
So check the headers returned by your 404 page then it may be an apache set up issue, as the php looks fine.
Internet Explorer on the other hand uses a default informative 404 page if there is no HTML content returned along with the 404 header.
Apache's 404 configuration only applies to plain old .html files that haven't been handled by a filter (e.g. PHP).
header('HTTP/1.x 404 Not Found');
include realpath($_SERVER['DOCUMENT_ROOT'] . '/../error_docs/not_found.html');