簡體   English   中英

https的IIS URL重寫規則並包含路徑

[英]IIS URL rewrite rule for https and containing path

我試圖找出一個URL重寫規則,以僅在訪問特定路徑(如下所示)時將http請求重寫為https。 我已經嘗試了很多事情,在測試模式中似乎它們應該可以工作,但是從不行。

訪問的網址: http : //example.com/books/test.css

我需要檢查http://和/ books /以便在下面形成正確的網址。

所需網址: https//example.com/books/test.css

應該忽略http://example.com/book/test.css的請求。

您可以在<match>元素中指定樣式:

<rule name="Force HTTPS for /books/" enabled="true">
    <match url="^/books/.*$" ignoreCase="false" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action type="Redirect" redirectType="Permanent"
            url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true"  />
</rule>

或添加新的<condition>

<rule name="Force HTTPS for /books/" enabled="true">
    <match url="(.*)" ignoreCase="false" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
        <add input="{REQUEST_URI}" pattern="^/books/.*$" />
    </conditions>
    <action type="Redirect" redirectType="Permanent"
            url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true"  />
</rule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM