小编Ben*_*err的帖子

IIS 7 在自定义 404 错误页面上返回 HTTP 200

我已成功为 IIS7 设置自定义静态错误页面。IIS7 目前用作 Java tomcat 应用程序的网关。问题在于,当提供 404 错误页面时,它会提供 HTTP 200 状态代码标头。我想要一种配置 IIS 以继续发送 HTTP 404 的方法。错误页面作为 webroot 中的静态页面存在。

这是我的 web.config 的主要部分:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="HTTP to HTTPS Redirect" enabled="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
            </rule>
            <rule name="Reverse Proxy" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:8080/{R:1}" />
                <conditions>
                    <add input="{R:1}" pattern="error/*." negate="true" />
                </conditions>
            </rule>
        </rules>
    </rewrite>
    <httpErrors errorMode="Custom" existingResponse="Auto">
        <remove statusCode="404" subStatusCode="-1" />
        <error statusCode="404" prefixLanguageFilePath="" path="/error/404.htm" responseMode="ExecuteURL" /> …
Run Code Online (Sandbox Code Playgroud)

iis-7 http-headers http-status-code-404

7
推荐指数
1
解决办法
8770
查看次数

标签 统计

http-headers ×1

http-status-code-404 ×1

iis-7 ×1