如何追加查询字符串&通过IIS重写规则的价值? [英] How to append query string & value via IIS rewrite rule?

查看:153
本文介绍了如何追加查询字符串&通过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}&amp;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>

这篇关于如何追加查询字符串&amp;通过IIS重写规则的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆