2012-11-10 40 views
21

我得到這個角色在URL重寫。那每個請求使用HTTP現場改寫爲HTTPSIIS除了一些網址

<rule name="Force HTTPS" stopProcessing="true"> 
        <match url="(.*)" /> 
        <conditions> 
         <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
        </conditions> 
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
       </rule> 

我需要其他的角色或異常在這個角色改寫背部或URL重寫角色將特定的網址重定向到HTTP。

是可能的嗎? 謝謝。

回答

54

您可以添加您不希望爲額外的條件(不等於URL)執行重定向到HTTPS例外,像這樣:

<rule name="Force HTTPS" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
     <add input="{REQUEST_URI}" negate="true" pattern="^/noredirect/forthis/page\.aspx$" ignoreCase="true" /> 
     <add input="{REQUEST_URI}" negate="true" pattern="^/noredirect/forthis/page-as-well\.aspx$" ignoreCase="true" /> 
     <add input="{REQUEST_URI}" negate="true" pattern="^/noredirect/forthis/page-as-well-too\.aspx$" ignoreCase="true" /> 
    </conditions> 
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
</rule> 
+0

它會是這樣>>< add input =「{REQUEST_URI}」negate =「true」pattern =「^/domain.com/directoryname/pageName\.aspx$」ignoreCase =「true」/>,?感謝回覆 – Mido

+2

只要domain.com是一個在你網站根目錄下的目錄,那麼是的,這將起作用。請注意,您應該在正則表達式中使用'domain \ .com'來與domain.com進行字面匹配,否則該點將使正則表達式接受任何字符。如果您打算將domain.com作爲域名進行匹配,則不能使用此名稱,因爲域名未包含在「{REQUEST_URI}」變量中。 –

+1

我使用IIS嚮導從URL寫入中排除特定域,並且它創建瞭如下所示的行: 在條件節點中。而SubStringOfURL是我想要排除的URL的子字符串。 –

相關問題