2013-05-15 51 views
3

现在只有一个页面和所有依赖项(css,jpg等)需要SSL。我创建了以下改写:Url Rewrite HTTPS - > HTTP除了某些页面(IIS 7)

<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> 

我试图把页面的名称在比赛中的URL(否定=“假”),仍然不起作用。

我测试了每个单独的条件,它们都单独工作,但作为一个整体,它不会重定向到非HTTPS页面。

回答

2

一个简单的方法是:

<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,则会触发重定向。

+0

欢呼声回复。我会给这个流行音乐,让你知道。 –