IIS URL 重写不适用于查询字符串
我认为这很简单,但它拒绝工作.旧网址是
I thought this was pretty straightforward, but it refuses to work. The old URL is
http://www.site.com/?q=node/17
它需要重定向到 http://www.site.com.我不需要担心通配符,这是我唯一需要担心的查询字符串参数.我写的规则看起来像
It needs to redirect to http://www.site.com. I don't need to worry about wildcards, this is the only query string parameter I need to worry about. The rule I wrote looks like
<rule name="Node17" patternSyntax="ExactMatch" stopProcessing="true">
<match url="http://www.site.com/?q=node/17" />
<action type="Redirect" url="http://www.site.com" appendQueryString="False" />
</rule>
我可以测试 IIS 内部的模式并且它匹配,但是当我在浏览器中点击 URL 时它不会重定向.有什么想法吗?
I can test the pattern inside of IIS and it matches, but when I hit the URL in a browser it doesn't redirect. Any thoughts?
当然,我发布后很快就想通了.这样做了,但不确定为什么精确匹配不起作用.
Of course I figured it out soon after I posted. This does it, not really sure why the exactmatch wasn't working though.
<rule name="Node17" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{QUERY_STRING}" pattern="q=node/17" />
</conditions>
<action type="Redirect" url="http://www.site.com" appendQueryString="False" />
</rule>