繁体   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