繁体   English   中英

IIS 重写设置 301 重定向

[英]IIS rewrite set 301 redirect

我想要这些 url 重定向。

示例 1:

http://wwww.old.com/News/Listhttp://wwww.new.com/News/List

示例 2:

http://wwww.old.com/News/List?page=1&type=2

http://wwww.new.com/News/List?page=1&type=2

示例 3:

http://wwww.old.comhttp://wwww.new.com

我的设置如下

<rewrite>
    <rules>
        <rule name="site2.com" stopProcessing="true">
            <match url=".*" />
            <conditions>
                <add input="{HTTP_HOST}" pattern="http://wwww.old.com" />
            </conditions>
            <action type="Rewrite" url="http://wwww.new.com/{R:0}" />
        </rule>
    </rules>
</rewrite>

{HTTP_HOST} 应该匹配wwww.old.com而不是http://wwww.old.com ,你可以将rewrite改成redirect ,这个规则你可以作为参考:

<rule name="test" stopProcessing="true">
   <match url="^(.*)$" />          
      <conditions>
         <add input="{HTTP_HOST}" pattern="^wwww.old.com$" />
      </conditions>
   <action type="Redirect" url="https://wwww.new.com/{R:0}" appendQueryString="true" />
</rule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM