-1

我在 web.config 中有以下重写规则

<rewrite url="~/product/(.+)" to="~/outbound-link-proxy.aspx?product=$1" />

这应该重写(例如)

mydomain.com/product/car

mydomain.com/outbound-link-proxy.aspx?product=car

这工作正常。但是我注意到有些网站链接到我的网站,并在最后添加了自己的查询字符串。我不介意这一点,但它打破了我的重写。

mydomain.com/product/car?foreignQueryString=983249

如何创建重写规则以保留我的原始重写但忽略任何查询字符串,以便

mydomain.com/product/car?foreignQueryString=983249

仍然重写为

mydomain.com/outbound-link-proxy.aspx?product=car
4

1 回答 1

0

这是答案

<rewrite url="~/product/(.+)\?(.+)" to="~/outbound-link-proxy.aspx?product=$1" />

一个 \?匹配文字问号,然后 (.+) 匹配任何其他字符的数量到字符串的结尾。

于 2013-09-07T16:18:52.620 回答