I'm looking for a way to redirect to an /error.php page when a fatal php error occurs. I have htaccess setup to log errors, but how can I redirect on fatal error using htaccess?
1 Answer
Use header with a shutdown function to forward them on fatal error.
register_shutdown_function('forward_fatal');
function forward_fatal(){
header("Location: error.php");
}
1 Comment
Supericy
Note that for this to work, you either enable output buffering or guarantee that no output has been sent prior to the error.