【发布时间】:2016-04-10 07:25:06
【问题描述】:
我想我正在尝试做一些应该简单的事情。我想要一个重写规则,它接受来自许多域的任何传入请求,并将其重写为 /redirect.aspx?src=original URL
这就是我所拥有的
<rewrite>
<rules>
<rule name="SimpleURL" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" negate="true" pattern="\.aspx$"/>
</conditions>
<action type="Redirect" url="/Redirect.aspx?src={R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
除了传递的查询参数是 src= 没有任何值之外,它可以工作。
我进行了更改,现在它为查询参数传递了一个硬编码值
I made a change so it is now passing a value for the parameter.
<rewrite>
<rules>
<rule name="SimpleURL" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{URL}" negate="true" pattern="\.aspx$"/>
<add input="{QUERY_STRING}" pattern="src=(.*)" negate="true" />
</conditions>
<action type="Redirect" url="/Redirect.aspx?src=foobar" appendQueryString="true" redirectType="Found" />
</rule>
</rules>
</rewrite>
如果我将 foobar 替换为 {R:0},则不会传递任何值。在此处输入代码硬编码的foobar值被传递。
【问题讨论】:
标签: iis url-rewriting