簡體   English   中英

IIS 重定向規則將一個 url 重定向到另一個

[英]IIS Redirect Rule to redirect one url to another

我知道這已經被問了很多,但我似乎無法弄清楚如何讓它工作,甚至查看其他變量。 我需要將 www.example.com/article-2 重定向到 www.example.com/article

 <rule name="Redirect Dup Artivcle URL" enabled="false" patternSyntax="Wildcard" stopProcessing="true"> <match url=".*" /> <conditions> <add input="{HTTP_HOST}{REQUEST_URI}" pattern=" https://www.example.com/article-2/" /> </conditions> <action type="Redirect" url="https://www.example.com/article/" appendQueryString="false" /> </rule>

我覺得我可能有錯誤的 URL 匹配模式...

很明顯,{HTTP_HOST} 沒有覆蓋 https://。 請像這樣修改規則

            <rule name="Redirect Dup Artivcle URL" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{HTTP_HOST}{REQUEST_URI}" pattern="www.example.com/article-2/" />
                <add input="{HTTPS}" pattern="^on$" />
            </conditions>
            <action type="Redirect" url="https://www.example.com/article/" appendQueryString="false" redirectType="Temporary" />
        </rule>

在此處輸入圖片說明

暫無
暫無

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

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