繁体   English   中英

Url重写HTTPS - > HTTP,但某些页面除外(IIS 7)

[英]Url Rewrite HTTPS -> HTTP except certain page (IIS 7)

现在只有一个页面,所有依赖项(css,jpg等)都是SSL。 我创建了以下重写:

  <rule name="Not Appointment Form 4.1 SSL" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
      <match url=".*" negate="false" />
      <conditions>
          <!-- check if https is on -->
          <add input="{HTTPS}" pattern="on" />

          <!-- I'm only interested in the aspx files -->
          <add input="{PATH_TRANSLATED}" pattern=".aspx$" /> 

          <!-- anything BUT the page to be secured -->
          <add input="{PATH_INFO}" pattern="page-to-be-secured.aspx" negate="true" /> 
      </conditions>
      <action type="Redirect" url="http://mydomain{PATH_INFO}" redirectType="Permanent" />
  </rule>   

我已经尝试将该页面的名称放在匹配网址(negate =“false”)中,但仍然无法正常工作。

我已经测试了每个单独的条件,它们都是单独工作的,但总的来说,它并没有重定向到非HTTPS页面。

一个简单的方法是:

<rule name="Not Appointment Form 4.1 SSL" stopProcessing="true">
    <match url="^(.*)\.aspx$" />
    <conditions>
        <add input="{R:1}" pattern="page-to-be-secured" negate="true" />
        <add input="{HTTPS}" pattern="^ON$" />
    </conditions>
    <action type="Redirect" url="http://{HTTP_HOST}/{R:0}" />
</rule>

该规则适用于以.aspx结尾的每个请求的URL。 如果与.aspx之前的部分对应的第一个后向引用( {R:1} )与要保护的page-to-be-secured不匹配并且正在使用HTTPS ,则会触发重定向。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM