Apache/PHP returns HTTP Status Code 200 on error pages

前端 未结 3 1102
囚心锁ツ
囚心锁ツ 2021-02-14 21:33

I\'m running PHP 5.4 on CentOS 7 and when there is a php file that throws an error (either an exception, or a syntax error) it returns an HTTP 200 status code instead of 500.

3条回答
  •  梦如初夏
    2021-02-14 22:12

    According to a PHP bug report, the behavior described here is due to how display_errors is set.

    [2010-02-03 19:03 UTC] derick@php.net

    The reason why display errors needs to be turned of, is because displayed errors generate output, and output causes the headers to be send out. I'm afraid we can't do much about this.

    So the answer to the question is that:

    • When display_errors is on it will return 200 always.
    • When display_errors is off it will return 500.

提交回复
热议问题