asp.net - 是否可以将 URL 重写规则仅应用于 Windows XP 上的 IE 浏览器?

标签 asp.net iis url-rewriting web-config

我目前有以下 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/

相关文章:

c# - 通过避免像点击事件这样的回发,使用 javascript 显示消息框。确定,取消按钮应该只关闭消息框

html - 如何在 Gridview 中并排显示 ItemTemplate 和 Alternating ItemTemplate?

sql-server - 让 IIS 在内网环境中模拟 Windows 用户访问 SQL Server

iis - HTTP 500.19 - 错误的配置文件路径

asp.net-mvc - 如何在 IIS 中使用带有 https 的域名而不是 localhost 来调试网站

php - 如何在安装了 php 的 IIS 上检查单个站点的传出 HTTP 请求?

.htaccess - 将 http 重定向到 https

c# - .net activex 在框架 4.0 中不工作

c# - Page.IsPostBack 的安全实现?

php - htaccess 重写 - 文件名无法识别