重定向到不同的域并更改查询字符串值

时间:2019-05-31 09:11:26

标签: asp.net iis url-rewriting

我需要在我的webconfig中编写一个URL重写规则,以更改URL的域,而且还更改存在的querystring值。

我需要改变

http://foo.com/login?id=1

https://bar.com/login?id=2

这是针对运行IIS 8.5且安装了URL重写模块的Windows Server 2012计算机。

到此为止,它可以正确地将URL重定向到新域,但是我不知道如何处理查询字符串,因此我一直在努力解决。

<rule name="Domain redirect">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
         <add input="{HTTP_HOST}" pattern="(.*)foo(.*)" />
    </conditions>
    <action type="Redirect" url="https://bar/{R:1}" appendQueryString="True" />
</rule>

0 个答案:

没有答案
相关问题