URL 用查询字符串重写
URL Rewrite with Query String
我正在 IIS 中编写重定向类型的重写规则。我希望新的 url 有一个新添加的查询字符串参数值。旧 url 没有任何查询字符串值。
实现此目标的最佳方法是什么?
旧url: abc.com/2017/Sample-Page
新 Url: 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>
我正在 IIS 中编写重定向类型的重写规则。我希望新的 url 有一个新添加的查询字符串参数值。旧 url 没有任何查询字符串值。
实现此目标的最佳方法是什么?
旧url: abc.com/2017/Sample-Page
新 Url: 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>