我正在尝试找出一种方法来修改HTTP 302找到(重定向)响应的Location标头中的单个查询字符串参数。
例如,如果响应中的Location标头为:
https://example.com/path?param1=a¶m2=z¶m3=c
我希望将其重写为:
https://example.com/path?param1=a¶m2=b¶m3=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¶m2=(.+)¶m3=c" />
<conditions>
<add input="{RESPONSE_STATUS}" pattern="^301" />
</conditions>
<action type="Rewrite" value="https://example.com/path?param1=a¶m2=b¶m3=c"/>
</rule>
</outboundRules>