
我有一個網站,我在其中編寫了 URL 重寫規則,以將所有 site.com 流量定向到 www.site.com。
工作正常。
現在我想將 SSL 添加到子目錄上的應用程式。我已將 SSL 添加到網站,但想要重定向所有訪問的流量http://www.site.com/application/到https://www.site.com/application
這是我想出來的:
<rule name="Redirect Supply Management System traffic to https" stopProcessing="true">
<match url="(.*)/supply-management-system/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="(.*)/supply-management-system/(.*)" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}/{R:2}" appendQueryString="true" />
</rule>
如果我測試這些模式,它們似乎都沒有問題,但是當我透過 http 導航到應用程式時,我不會被重定向。
任何想法都會很棒,謝謝!
答案1
這有效:
<rule name="Redirect Supply Management System traffic to https" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(^supply-management-system/.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" />
</rule>