IIS中的HTTP重写规则未激活

时间:2019-07-18 09:22:48

标签: http iis url-rewriting

我有一个类似的网站

  

www.domainfullname.com

并且我需要创建一个规则,如果我键入

  

www.domainname.com   要么   domainname.com

已激活到www.domainfullname.com的重定向。

因此,我尝试创建一个空白规则并设置以下参数:
格式:* domainname.com *
行动-重写URL:http:\\ www.domainfullname.com \ {R:1}
但这是行不通的。没有重定向发生。我在做什么错了?

1 个答案:

答案 0 :(得分:0)

您可以使用以下URL重写规则:

 <rule name="redirect to sample 2 with www or non www" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="sample1.com|www.sample1.com" />
                    <add input="{REQUEST_URI}" pattern=".*" />
                </conditions>
                <action type="Redirect" url="http://www.sample2.com/{R:1}" />
            </rule>

enter image description here enter image description here

注意:如果要重写页面,可以将操作类型更改为重写。

相关问题