【问题标题】:IIS php header 404 call won't use deafult error pageIIS php 标头 404 调用不会使用默认错误页面
【发布时间】:2018-04-06 02:39:21
【问题描述】:

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

【问题讨论】:

  • 我也试过 header('Status: 404 Not Found');http_response_code(404); 没有运气

标签: php iis http-headers


【解决方案1】:

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

<configuration>
   <system.webServer>

添加行:

<httpErrors existingResponse="Replace" />

更多信息在这里:https://docs.microsoft.com/en-us/iis/configuration/system.webServer/httpErrors/#attributes

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    • 2017-03-15
    • 1970-01-01
    • 2011-10-04
    • 1970-01-01
    • 2011-01-01
    相关资源
    最近更新 更多