IIS重写集301重定向

k5hmc34c  于 2022-12-27  发布在  其他
关注(0)|答案(1)|浏览(122)

我想这些网址重定向。
实施例1:
http://wwww.old.com/News/Listhttp://wwww.new.com/News/List
实施例二:
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>
8wigbo56

8wigbo561#

{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>

相关问题