IIS 7 URL重写 - 获取查询字符串的值

时间:2011-09-13 13:30:51

标签: iis-7 url-rewriting

我试图从这个网址重新开始......

/Search/VehicleDetails.aspx?vehicle=285584

到这个

/VehicleAdvert/tella/Friend/285584

到目前为止,我一直在玩规则,并且有这个,这不起作用......

<!-- Tell a Friend -->
<rule name="Tell a Friend" stopProcessing="true">
  <match url="^.*(?:Search/VehicleDetails.aspx).*$" />
  <conditions>
    <add input="{QUERY_STRING}" pattern="vehicle=.*" />
  </conditions>
  <action type="Redirect" url="/VehicleAdvert/tella/Friend" redirectType="Permanent" appendQueryString="true" />
</rule>

我回来的网址是/VehicleAdvert/tella/Friend?vehicle=285584

后面是什么 - &gt; /VehicleAdvert/tella/Friend/285584

任何人都可以建议我哪里出错?

提前感谢:)

Truegilly

1 个答案:

答案 0 :(得分:9)

这解决了它

<!-- Tell a Friend -->
<rule name="Tell a Friend" stopProcessing="true">
  <match url="^.*(?:Search/VehicleDetails.aspx).*$" />
  <conditions>
    <add input="{QUERY_STRING}" pattern="vehicle=(\d+)" />
  </conditions>
  <action type="Redirect" url="/VehicleAdvert/tella/Friend/{C:1}" redirectType="Permanent" appendQueryString="false" />
</rule>