Forum Moderators: coopster
Here are a few tips that may save you time if you are in a similar situation:
1. Check to see whether PHP is running as a CGI interpreter or an Apache module. Do this by running the phpinfo() function to check how your server is configured. You can tell if it's running as a module 'cos the "Server API" variable shows a value of 'Apache'. Else, "Server API" is set to "CGI".
If it's running as a CGI version, making a custom 404 page is going to be a little bit more tricky. See this thread [webmasterworld.com...]
(My hosting package ran PHP4 as a CGI version by default but allowed me alter the configuration, using the .htaccess file, to tell it to run as an Apache module)
2. Create a file called 404.php (or your choice of filename) in the directory where you keep your public html files. Then fill it with some test content.
VERY IMPORTANT : Put a sizable amount of test-content into this file. e.g about 300 characters, at least, of 'sfdfndfdnf ' or 'blah blah blah'. This is because, (I quote from [phpbuilder.com...] )"You simply need to make sure your 404 script is generating enough
output. For some weird reason M$ decided to substitute their own 404 page
if the remote server sends less than a certain amount of bytes. Right now
I don't recall exactly what that magic number might be. Try experimenting
a bit and let us know.
-Rasmus"
(This where i went wrong and it took me ages to discover the problem. I had previously just put 'this is a 404 page' - and it didn't show up for the reasons explained above.)
3. Place this directive in your .htaccess file:
ErrorDocument 404 /404.php
Where '/404.php' is the file you want to use as the custom 404 page.
(I came this forum after searching google whilst trying to solve a problem i had with customizing a 404 error handling page on my php4 apache virtual server
and read the discussion here:
[webmasterworld.com...]
I tried to add this comment to that thread, but was not allowed by the forum settings - the topic was too old)