我目前有以下 URL 重写规则(感谢 smarx's post ):
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
它将所有 HTTP 流量重定向到 HTTPS - 因此所有站点都立即受到保护。由于某些原因(SNI、Azure、Windows XP - 它很复杂 - 如果需要,请阅读 here)我需要为 Windows XP IE 浏览器保留 HTTP。可以在 web.config 中做吗?如果是 - 我该怎么做?我想我需要检查 HTTP header ,但是怎么做呢?..
如果重要的话,我正在使用 II8 和 ASP.NET MVC4。
最佳答案
从技术上讲,罗伯特的回答是正确的 - 我只想分享我想出的确切正则表达式:
<add input="{HTTP_USER_AGENT}" pattern="^(?=.*?MSIE)(?=.*?Windows NT 5\.).*$" negate="true" />
这将从我的规则中排除 Windows XP IE 浏览器。
关于asp.net - 是否可以将 URL 重写规则仅应用于 Windows XP 上的 IE 浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20500495/