2017-03-21 38 views
1

在使用Windows 2006 R2的VPS上我想編輯web.config文件,以便在幾個子文件夾中找到的所有頁面都從http重定向到https。使用web.config強制http對特定子文件夾的https IIS

我在下面找到了這個建議,我想知道的是如何列出這個重寫規則將被應用的特定文件夾。

的子文件夾:

/SECURE1/

/secure2/

/ADMIN1/

/Admin2的/

任何幫助和建議將不勝感激:)

<configuration> 
<system.webServer> 
    <rewrite> 
     <rules> 
      <clear /> 
      <rule name="Redirect to https" stopProcessing="true"> 
       <match url=".*" /> 
       <conditions> 
        <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
       </conditions> 
       <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> 
      </rule> 
     </rules> 
    </rewrite> 
</system.webServer> 

+0

您好NepCoder,爲您的解決方案的感謝。我會在今天晚些時候嘗試一下並提供反饋。 –

+0

您是否能夠正常工作? – NepCoder

+0

嘿!謝謝你的跟進。這是一個瘋狂的忙碌的一週,我打算早點報告。代碼是在...服務器重寫模塊,但是另一個問題LOL。經過一番研究,似乎有解決方法,但他們需要目前我沒有的專業水平。我將在幾個月內將該網站遷移到Windows 2012環境中,然後再測試一切。再次感謝您的幫助:) –

回答

0

這樣的事情呢?

<rule name="test" stopProcessing="true"> 
    <match url="(secure1|secure2|admin1|admin2).*" /> 
    <conditions> 
     <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
    </conditions> 
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> 
</rule> 

得到了這個網址的信息,如果您想了解更多: https://forums.iis.net/t/1176994.aspx?Https+Redirect+for+certain+folders+sections+only

相關問題