보통 404 에러시 htaccess 파일에
ErrorDocument 404 /404.html
이렇게 하면 자동으로 이동하는데
ErrorDocument 500 /500.html
500 에러시에는 이동하지 않습니다.
set_error_handler 함수를 이용하여 각 페이지 마다 처리해야 하는건지요?
답변 2개 / 댓글 2개
https://serverfault.com/a/675348
https://stackoverflow.com/a/51793178
"This is normal behavior, as PHP errors aren't considered 5xx Server Errors."
기본적으로는 안된다고 나와 있습니다.
차선책으로 다음의 방법을 검토해 볼 수 있는 듯 합니다.
https://webmasters.stackexchange.com/a/115593
function shutDownFunction() {
$error = error_get_last();
if ($error && ($error['type'] == E_PARSE || $error['type'] == E_ERROR)) {
//echo 'An error occured!';
header('Location: ./500.html');
}
}
register_shutdown_function('shutDownFunction');
답변에 대한 댓글 1개
https://httpd.apache.org/docs/2.4/custom-error.html
ErrorDocument 500 /cgi-bin/crash-recover
ErrorDocument 500 "Sorry, our script crashed. Oh dear"
ErrorDocument 500 http://xxx/
여러 가지 방법이 나와 있네요.
답변에 대한 댓글 1개
404 에러만 적용됩니다.
혹시 제가 잘못 적용한건지는 모르지만요...
실제 적용하신적이 있으시면 상세히 설명 부탁드립니다.
답변을 작성하려면 로그인이 필요합니다.
적용해보도록 하겠습니다.