感谢这个论坛,我了解到 PHP header 函数实际上不会将 header 发送到 Apache 服务器,而只会发送到客户端。
我想做的是产生一个错误500,让Apache显示它对应的页面。有没有办法强制执行?
提前致谢! (和 allez les bleus !)
最佳答案
有一种方法可以向浏览器发送 500 错误,但您必须自己提供页面:
<?php
header('HTTP/1.1 500 Internal Server Error');
echo <<<ERRORTEXT
The server encountered an unexpected condition which prevented it
from fulfilling the request.
ERRORTEXT;
// also notify server operator, maybe?
exit;
?>
关于PHP 强制 Apache 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3004407/