Custom error pages for .php web pages? Help with htaccess
Posted: Mon Jan 23, 2006 1:20 pm
A site has the following htaccess commands in it for custom error pages:
ErrorDocument 400 /error.php?code=400
ErrorDocument 401 /error.php?code=401
ErrorDocument 403 /error.php?code=403
ErrorDocument 404 /error.php?code=404
ErrorDocument 405 /error.php?code=405
ErrorDocument 500 /error.php?code=500
ErrorDocument 501 /error.php?code=501
ErrorDocument 502 /error.php?code=502
ErrorDocument 503 /error.php?code=503
ErrorDocument 504 /error.php?code=504
So, there is one error page with php code in it. Depending on the error code that Apache sends, it will display the correct error message on the website.
However, if I type in http://www.domain.com/fdfdsfsdf.html I will get the error page correctly. However, if I type http://www.domain.com/fdfdsfsdf.php, it does not use the custom page, but using the default apache not found page. Is there something else I need to add to the htaccess file to make php errors use the custom page?
I was told by the owner of the hosting company I work at that every time apache sees a .php extension, it automatically assumes it is a script and will not parse the correct error message for it.
Does anyone know how to get .php extensions to use the custom error page on an apache server? Is there something else I can add to the htaccess file to facilitate this?
ErrorDocument 400 /error.php?code=400
ErrorDocument 401 /error.php?code=401
ErrorDocument 403 /error.php?code=403
ErrorDocument 404 /error.php?code=404
ErrorDocument 405 /error.php?code=405
ErrorDocument 500 /error.php?code=500
ErrorDocument 501 /error.php?code=501
ErrorDocument 502 /error.php?code=502
ErrorDocument 503 /error.php?code=503
ErrorDocument 504 /error.php?code=504
So, there is one error page with php code in it. Depending on the error code that Apache sends, it will display the correct error message on the website.
However, if I type in http://www.domain.com/fdfdsfsdf.html I will get the error page correctly. However, if I type http://www.domain.com/fdfdsfsdf.php, it does not use the custom page, but using the default apache not found page. Is there something else I need to add to the htaccess file to make php errors use the custom page?
I was told by the owner of the hosting company I work at that every time apache sees a .php extension, it automatically assumes it is a script and will not parse the correct error message for it.
Does anyone know how to get .php extensions to use the custom error page on an apache server? Is there something else I can add to the htaccess file to facilitate this?