简体   繁体   English

IIS 重定向规则将一个 url 重定向到另一个

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

I Know this has been asked a lot but I just can't seem to figure out how to get this to work, even looking at other variables.我知道这已经被问了很多,但我似乎无法弄清楚如何让它工作,甚至查看其他变量。 I need to redirect www.example.com/article-2 to www.example.com/article我需要将 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>

I feel like I may have the wrong URL matching pattern...我觉得我可能有错误的 URL 匹配模式...

Its obviously that {HTTP_HOST} is not covering https://.很明显,{HTTP_HOST} 没有覆盖 https://。 Please modify the rule like this请像这样修改规则

            <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