如何附加查询字符串 &值通过 IIS 重写规则? [英] How to append query string & value via IIS rewrite rule?
本文介绍了如何附加查询字符串 &值通过 IIS 重写规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行 IIS 7,并安装了官方重写规则模块.我想创建一个重写规则来匹配这个 URL:
I'm running IIS 7 with the offical rewrite rule module installed. I'd like to create a rewrite rule to match this URL:
http://www.sample.com/en-us/test.aspx?q=keyword
重写后的预期结果是:
http://www.sample.com/en-us/test.aspx?q=keyword&flag=value
如何创建规则来实现这一点?
How can I create a rule to implement this?
我已经测试了以下规则,但没有运气,它总是出现重定向循环错误:
I've tested the following rule, but no luck, it always got redirect loop error:
<rewrite>
<rules>
<rule name="test" stopProcessing="true">
<match url="(.*)/test.aspx(.(?!flag=value))*$" />
<action type="Redirect" url="{R:0}&flag=value" appendQueryString="false" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
推荐答案
自己找到的解决方案,分享一下.
Found the solution by myself, just share it.
<rewrite>
<rules>
<rule name="Redirect for download result page" stopProcessing="true">
<match url="(.*)/test.aspx(.*)" />
<action type="Redirect" url="{R:1}/test.aspx?rf=sp" appendQueryString="true" redirectType="Found" />
<conditions>
<add input="{QUERY_STRING}" pattern="flag=value" negate="true" />
</conditions>
</rule>
</rules>
</rewrite>
这篇关于如何附加查询字符串 &值通过 IIS 重写规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文