IIS URL 重写不适用于查询字符串 [英] IIS URL Rewrite not working with query string

查看:24
本文介绍了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>

这篇关于IIS URL 重写不适用于查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆