IIS URL重写模块-更改查询字符串参数值以形成多个查询字符串

问题描述 投票:0回答:1
   <rule name="replace query string" enabled="true" stopProcessing="true">
                    <match url="(.*)(ip=1)(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{QUERY_STRING}" pattern="(.*)(ip=1)(.*)" />
                    </conditions>
                    <action type="Redirect" url="{R:0}?{C:0}ip=0{C:2}" appendQueryString="false" logRewrittenUrl="true" />
                </rule>

我已经使用了上面的规则及其创建重复的查询字符串

我在下面的网址中使用过

http://test.com/track/?ip=1&_=1589821794782

我的主要目标是将test.com更新为api.com,然后将ip = 1更改为ip = 0。

您能帮我,我是新来的吗?

生成的URL http://test.com/track/?ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=0&=1589821794782&ip=1&=1589821794782

enter image description here

redirect iis iis-7 iis-express url-rewrite-module
1个回答
1
投票

您的规则模式中存在一些问题。您可以看到以下规则失败的请求跟踪结果:

enter image description here

为了退休,您可以尝试使用以下规则:

<rule name="replace query string" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="test.com" />
                    <add input="{QUERY_STRING}" pattern="ip=1(.*)" />
                </conditions>
                <action type="Redirect" url="http://api.com/{R:1}?ip=0{C:1}" appendQueryString="false" logRewrittenUrl="true" />
            </rule>
© www.soinside.com 2019 - 2024. All rights reserved.