Ben*_*err 7 iis-7 http-headers http-status-code-404
我已成功为 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" />
</httpErrors>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
切换到 usingresponseMode="File"
但是,除非您解锁或设置为 true ,否则此技巧将使用相对文件路径system.webServer/httpErrors allowAbsolutePathsWhenDelegated
。
web.config 摘录示例:
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="error\404.htm" responseMode="File" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8770 次 |
最近记录: |