500 에러시 다른 페이지로 이동

500 에러시 다른 페이지로 이동

QA

500 에러시 다른 페이지로 이동

답변 2

본문

보통 404 에러시 htaccess 파일에

ErrorDocument 404 /404.html

이렇게 하면 자동으로 이동하는데 

ErrorDocument 500 /500.html

500 에러시에는 이동하지 않습니다.

 

set_error_handler 함수를 이용하여 각 페이지 마다 처리해야 하는건지요?

이 질문에 댓글 쓰기 :

답변 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');

 

 

 

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/

 

여러 가지 방법이 나와 있네요.

apache 설정 파일을 수정해도 마찬가지로 안됩니다.
404 에러만 적용됩니다.
혹시 제가 잘못 적용한건지는 모르지만요...
실제 적용하신적이 있으시면 상세히 설명 부탁드립니다.

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 0
© SIRSOFT
현재 페이지 제일 처음으로