IIS URL 重写模块:基于 QueryString 重定向 [英] IIS URL Rewrite Module : Redirect Based On QueryString

查看:19
本文介绍了IIS URL 重写模块:基于 QueryString 重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在根据查询字符串参数重定向到另一个 URL 时遇到了一些问题.我想将输入 www.domain.com/signup.aspx?p=1 的用户重定向到:

I Have some problems with redirecting to another URL based on the query string parameters. I want to redirect users which enter www.domain.com/signup.aspx?p=1 to:

www.domain.com/signup

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 时,他们必须转到:

Now when they enter www.domain.com/signup.aspx?p=2 they must go to:

www.domain.com/signup/promocode

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>

以上规则不起作用.这样做的正确方法是什么?提前致谢.

The above rules don't work. What is the right way to do this? Thanks in Advance.

马丁

推荐答案

看看是否效果更好:

<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>

这篇关于IIS URL 重写模块:基于 QueryString 重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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