我正在使用iis-7.5和web.config文件。
我想将"somepage.asp?id=63"重定向到"somepage/10.html"。
我的web.config是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301 Redirect 2" stopProcessing="true">
<match url="somepage.asp?id=63" />
<action type="Redirect" url="somepage/10.html" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>它不起作用,当我把<match url="somepage.asp?id=63" />改成<match url="somepage.asp" /> (删除?id=63)时,它起作用了,为什么?我该怎么做呢?
发布于 2019-04-29 11:28:39
据我所知,url重写匹配url模式与查询字符串不匹配。
如果你想根据查询字符串重定向url,我建议你可以尝试使用condition。
更多细节,你可以参考下面的url重写规则:
<rule name="Redirect according to query string" stopProcessing="true">
<match url="somepage.asp" />
<conditions>
<add input="{QUERY_STRING}" pattern="id=63" />
</conditions>
<action type="Redirect" url="somepage/10.html" appendQueryString="false" />
</rule>https://stackoverflow.com/questions/55887251
复制相似问题