MyB*_*ome 9 iis url url-rewrite-module
我认为这很简单,但它拒绝工作.旧的URL是
http://www.site.com/?q=node/17
它需要重定向到http://www.site.com.我不需要担心通配符,这是我唯一需要担心的查询字符串参数.我写的规则看起来像
<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>
Run Code Online (Sandbox Code Playgroud)
我可以测试IIS内部的模式并匹配,但是当我在浏览器中点击URL时它不会重定向.有什么想法吗?
Ron*_*nyK 18
了解如何从重写规则访问URL字符串的某些部分非常重要.
对于此格式的HTTP URL:http(s):// {host}:{port}/{path}?{querystring}
{path}与规则的模式匹配.{querystring}在名为QUERY_STRING的服务器变量中可用,可以使用规则中的条件进行访问.
规则条件允许为规则评估定义附加逻辑...在规则模式匹配成功后评估规则条件.
在URL你想改写为重定向,你{host} = "www.site.com",{path} = ""和{querystring} = "q=node/17".因此,{path}您要重定向的网址中的部分实际上是空的,并且您在问题中使用的规则与之匹配且不匹配.
你的解决方案确实有效,所以我在这里引用它:
<rule name="Node17" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{QUERY_STRING}" pattern="q=node/17" />
</conditions>
<action type="Redirect" url="http://www.example.com" appendQueryString="False" />
</rule>
Run Code Online (Sandbox Code Playgroud)
当然,我发布后不久便想出来了.这样做,不确定为什么完全匹配不起作用.
<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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18222 次 |
| 最近记录: |