Although I'm sure it's possible I cannot see how I would be able to do the following.
Using .htaccess to point the html errors to a single error handling page (this bit not a a problem).
That page then checks what the error code actually was (404, 500 etc.) and displays a message according to each one.
I am trying to do it in a PHP environment, and it's for a minimalistic site so the less files the better.
This is an example of a 404 I'm producing, http://isitup.org/404, and all I want is to switch the number accordingly.
-
I always put in my .htaccess:
ErrorDocument 403 /error.php?error=403 ErrorDocument 404 /error.php?error=404 ErrorDocument 500 /error.php?error=500etc for whatever errors I want, then just switch case on $_GET['error'].
Don't think there is any more sophisticated way of doing it.
Sam : Thanks, that's so simple :P -
Since you're using .htaccess to redirect errors to a custom error handler file, you can use
$_SERVER['REDIRECT_STATUS']to obtain the HTTP error code. Based on that, you can display a different message depending on the error code.
0 comments:
Post a Comment