2013-05-15 95 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

歡呼聲回覆。我會給這個流行音樂,讓你知道。 –