IIS php标头404调用不会使用deafult错误页面

时间:2018-04-06 02:39:22

标签: php iis http-headers

当我运行header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');时,IIS 8.5(在Windows Server 2012r2上使用php 5.6.31)只显示一个空白页面。但是,页眉报告404状态代码。如何使IIS显示页面实际不存在时发送的默认错误页面?

1 个答案:

答案 0 :(得分:0)

我找到了答案。在web.config中,在:

<configuration>
   <system.webServer>

添加以下行:

<httpErrors existingResponse="Replace" />

此处提供更多信息:https://docs.microsoft.com/en-us/iis/configuration/system.webServer/httpErrors/#attributes