我在根据查询字符串参数重定向到另一个URL时遇到了一些问题。我想将输入www.domain.com/signup.aspx?p=1的用户重定向到:
www.domain.com/signup
<rule name="Signup Redirect 1" stopProcessing="true">
<match url="signup\.aspx\?p=1" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup" redirectType="Temporary" />
</rule>
现在当他们进入www.domain.com/signup.aspx?p=2时,他们必须去:
www.domain.com/signup/promocode
<rule name="Signup Redirect 2" stopProcessing="true">
<match url="signup\.aspx\?p=2" />
<conditions logicalGrouping="MatchAll" />
<action type="Redirect" url="signup/promocode" redirectType="Temporary" />
</rule>
以上规则不起作用。这样做的正确方法是什么?在此先感谢。
的Gr
马亭
答案 0 :(得分:38)
答案 1 :(得分:31)
看看这是否有效:
<rule name="Signup Redirect 1" stopProcessing="true">
<match url="signup\.aspx$" />
<conditions>
<add input="{QUERY_STRING}" pattern="p=1" />
</conditions>
<action type="Redirect" url="signup" redirectType="Temporary" />
</rule>
<rule name="Signup Redirect 2" stopProcessing="true">
<match url="signup\.aspx$" />
<conditions>
<add input="{QUERY_STRING}" pattern="p=2" />
</conditions>
<action type="Redirect" url="signup/promocode" redirectType="Temporary" />
</rule>