使用查询字符串重写URL [英] URL Rewrite with Query String

查看:201
本文介绍了使用查询字符串重写URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS中使用Redirect类型编写重写规则。我希望新的url有一个新添加的查询字符串参数值。旧网址没有任何查询字符串值。

I am writing a rewrite rule in IIS with type Redirect. I want the new url to have a query string parameter value added newly to it. The old url does not have any query string values.

达到此目的的最佳方式是什么?

What is the best way to achieve this?

旧网址:abc.com/2017/Sample-Page

新网址:test.abc.com/2017/Sample- Page?redirect = y

<rule name="rewrite with query string" stopProcessing="true">
    <match url="(.*)2017/Sample-Page(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="abc.com" />
    </conditions>
    <action type="Rewrite" url="http://test.abc.com/{R:0}?redirect=y"/>
  </rule>


推荐答案

这有效:

<rule name="rewrite with query string" stopProcessing="true">
    <match url="(.*)2017/Sample-Page(.*)" />
    <conditions>
      <add input="{HTTP_HOST}" pattern="abc.com" />
    </conditions>
    <action type="Rewrite" url="http://test.abc.com/{R:0}?redirect=y"/>
  </rule>

这篇关于使用查询字符串重写URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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