header redirect not working
I'm tyring to use the code below to re-direct to an error page with the header() function, but for some reason it's not working. I know I must be doing something stupid -- I've been working on it for a few hours and can't figure it out. Any help would be appreciated. Oh, and headers aren't being sent before I reach this point... I had a check in there for that just to make sure (which I'll probably throw back in there) but I took it out to simplify the code while debugging.
try {
SUR_Controller::route();
} catch (Exception $e) {
$codes = array( 401 => '401 Unauthorized',
403 => '403 Forbidden',
404 => '404 Not Found',
500 => '500 Internal Server Error');
$error = ($e->getCode() == 0) ? 500 : $e->getCode();
if (in_array($error, $codes)) {
header($_SERVER['SERVER_PROTOCOL'] . $codes[$error]);
exit();
}
}
|