【问题标题】:SSL Rule Exception in ASP.NET web.configASP.NET web.config 中的 SSL 规则异常
【发布时间】:2012-02-08 22:58:05
【问题描述】:

我有一个 SSL 证书,并在我的 web.config 中设置了一个重写规则,以将所有流量定向到 https。这工作正常(如果有人觉得它有用,下面的代码),但是我现在有一项服务我要向我的手机客户端公开,我不希望它使用 HTTPS。

我可以创建一个例外吗?所以对 www.mydomain.com/PhoneService/Seek.svc 的任何请求都不会重定向到https://www.mydomain.com.....

<rewrite>
      <rules>
          <rule name="HTTP to HTTPS redirect" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                  <add input="{HTTPS}" pattern="off" ignoreCase="true" />
              </conditions>
              <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
          </rule>
      </rules>
  </rewrite>

【问题讨论】:

    标签: asp.net wcf iis ssl rewrite


    【解决方案1】:

    您可以在规则中使用另一个条件来确保路径不以seek.svc 结尾:

    <rules> 
      <rule name="HTTP to HTTPS redirect" stopProcessing="true"> 
          <match url="(.*)" /> 
          <conditions>
            <add input="{HTTPS}" pattern="off" />
            <add input="{URL}" pattern="seek\.svc$" ignoreCase="true" negate="true" /> 
          </conditions> 
          <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> 
      </rule> 
    </rules>
    

    行:

    <add input="{URL}" pattern="seek\.svc$" ignoreCase="true" negate="true" /> 
    

    检查URL 变量并以seek.svc 结尾。我们否定条件,因为我们只希望规则在匹配时应用。

    【讨论】:

    • 注意:我将它从 {PATH_INFO} 编辑到 {URL} 为that is more correct
    • 太棒了,正是我所追求的。
    猜你喜欢
    • 1970-01-01
    • 2019-08-02
    • 2021-01-21
    • 2016-12-17
    • 1970-01-01
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 2015-01-26
    相关资源
    最近更新 更多