Re: Capturing 404s with PHP, slight twist
| From: | Ernest E Vogelsinger | Date: | Fri, 23 May 2003 15:51:48 +0000 |
| Subject: | Re: Capturing 404s with PHP, slight twist | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148791@lists.php.net to get a copy of this message | ||
At 17:23 23.05.2003, Jeff Lewis said:
--------------------[snip]--------------------
>The full htaccess is as follows:
>
>ErrorDocument 400 /errors.php?code=400
>ErrorDocument 401 /errors.php?code=401
>ErrorDocument 403 /errors.php?code=403
>ErrorDocument 404 /errors.php?code=404
>ErrorDocument 500 /errors.php?code=500
>
>Here is the image src tag:
>
><img src="Jason_Larue.bmp" width=90>
--------------------[snip]--------------------
You don't need the error code in the URL - maybe this is why the
appropriate $_SERVER entries are missing. You can always find the error
code in REDIRECT_STATUS.
This always works for me:
-- .htaccess --
ErrorDocument 403 /errors.php
ErrorDocument 404 /errors.php
ErrorDocument 500 /errors.php
-- errors.php --
switch ($_SERVER['REDIRECT_STATUS']) {
case 403:
handle_403_error();
break;
case 404:
handle_404_error();
break;
case 403:
handle_505_error();
break;
default:
handle_any_other_error();
}
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/