繁体   English   中英

IIS URL Rewrite 用于修改出站重定向响应的查询参数

[英]IIS URL Rewrite for modifying query parameter on outbound redirect response

我正在尝试找出一种方法来修改 HTTP 302 Found(重定向)响应的 Location 标头中的单个查询字符串参数。

例如,如果响应中的 Location 标头是:

https://example.com/path?param1=a&param2=z&param3=c

我希望将其重写为:

https://example.com/path?param1=a&param2=b&param3=c

这可能使用出站 IIS URL 重写规则吗?

根据您的描述,我建议您可以尝试使用以下 url 重写规则来实现您的要求。

<outboundRules>
    <!-- This rule changes the domain in the HTTP location header for redirection responses -->
    <rule name="Change Location Header">
        <match serverVariable="RESPONSE_LOCATION" pattern="^https://example.com/path?param1=a&param2=(.+)&param3=c" />
        <conditions>
            <add input="{RESPONSE_STATUS}" pattern="^301" />
        </conditions>
        <action type="Rewrite" value="https://example.com/path?param1=a&param2=b&param3=c"/>
    </rule>
</outboundRules>

暂无
暂无

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

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