2012-01-12 54 views
2

我有一個SSL證書,並在我的web.config中設置了一個重寫規則,以將所有流量定向到https。這工作正常(下面的代碼,如果任何人認爲它有用),但是我現在有一個服務,我暴露給我的手機客戶端,我不希望它使用HTTPS。ASP.NET中的SSL規則異常web.config

我可以創建異常嗎?因此,對於任何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> 

回答

3

您可以使用另一個條件您的規則,以確保道路並沒有結束在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結束。我們否定條件,因爲我們只希望規則適用,如果它不匹配匹配。

+0

注意:我將它從{PATH_INFO}編輯爲{URL},因爲[更正確](http://msdn.microsoft.com/zh-cn/library/ms524602%28v=VS.90%29。 ASPX)。 – vcsjones 2012-01-12 17:06:50

+0

輝煌,就是我之後的事情。 – Paul 2012-01-12 17:11:47