当我运行header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
时,IIS 8.5(在Windows Server 2012r2上使用php 5.6.31)只显示一个空白页面。但是,页眉报告404状态代码。如何使IIS显示页面实际不存在时发送的默认错误页面?
答案 0 :(得分:0)
我找到了答案。在web.config中,在:
下<configuration>
<system.webServer>
添加以下行:
<httpErrors existingResponse="Replace" />
此处提供更多信息:https://docs.microsoft.com/en-us/iis/configuration/system.webServer/httpErrors/#attributes