Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iis 重写web.config中的URL,但忽略查询字符串_Iis_Url Rewriting - Fatal编程技术网

Iis 重写web.config中的URL,但忽略查询字符串

Iis 重写web.config中的URL,但忽略查询字符串,iis,url-rewriting,Iis,Url Rewriting,我在web.config中有以下重写规则 <rewrite url="~/product/(.+)" to="~/outbound-link-proxy.aspx?product=$1" /> 到 这很好用。然而,我注意到一些网站正在链接到我的网站,并在最后添加自己的查询字符串。我不介意,但它打破了我的重写 mydomain.com/product/car?foreignQueryString=983249 如何创建重写规则以保留原始重写,但忽略任何查询字符串,以便 mydoma

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

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

这很好用。然而,我注意到一些网站正在链接到我的网站,并在最后添加自己的查询字符串。我不介意,但它打破了我的重写

mydomain.com/product/car?foreignQueryString=983249
如何创建重写规则以保留原始重写,但忽略任何查询字符串,以便

mydomain.com/product/car?foreignQueryString=983249
仍然重写为

mydomain.com/outbound-link-proxy.aspx?product=car
答案是这样的

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

A\?若要匹配文字问号,请使用(++)将任何其他字符的数目匹配到字符串的结尾

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