Forum Moderators: coopster
Not sure whether this is a php problem or an apache problem.
I have a php script that generates a 404 header in some circumstances (then exits). However the custom error page doesnt appear. I just get a totally empty page.
'Proper' missing web pages do trigger my custom 404 page. The custom page is configured in an .htaccess file at the site root.
I've run the server header check [webmasterworld.com] on this site and get the following:
HTTP/1.1 404 Not Found
Date: Thu, 11 May 2006 11:54:08 GMT
Server: Apache/2.0.52 (Red Hat)
X-Powered-By: PHP/4.3.9
Set-Cookie: ELCWeb=5db284b7d0ebcfad3c63c1012d944bef; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 0
Connection: close
Content-Type: text/html; charset=ISO-8859-1
This seems to imply that the correct header is returned but apache is not responding properly. Any ideas?
However, it's easy to work around this:
header("HTTP/1.1 404 Not Found");
include($_SERVER['DOCUMENT_ROOT'].'/path/to/custom_404.php');
die;
(Although I actually put the header and the die in the custom_404.php page and just include it when appropriate.)