url-rewriting - iis7.5,web.config 如何将不存在的文件(页面)重定向到另一个页面?
问题描述
我正在使用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" />
, (delete ?id=63) 时,它起作用了,为什么?我能怎么做?
解决方案
据我所知,url 重写匹配 url 模式与查询字符串不匹配。
如果你想根据查询字符串重定向url,我建议你可以尝试使用条件。
更多细节,你可以参考下面的 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>
推荐阅读
- python - Pandas 数据框 - to_json() to_csv() 对于 iso 格式的日期的行为不同
- angular - 在角度元标记中显示特殊字符?
- postman - 邮递员:如何从响应中获取数字字符串值的计数
- python - Python/Stripe 发票创建未添加 line_item
- java - 为什么我不能创建内部类的实例?
- r - 从网络中获取加权矩阵
- java - XML 命名空间异常
- python - 从 groupby 熊猫中获取 MultiIndex
- javascript - Javascript 的 Math.random() 如何在幕后工作?
- java - 如何在java中调用dll文件