【发布时间】:2013-02-20 14:16:33
【问题描述】:
IIS 中有没有办法重定向以下请求:
http://mysite/report1/img/logo.png 到 http://mysite/myapplication/report1/images/logo.png 用于 img 目录中的所有图像,而无需单独显式映射它们?
附加要求——我在映射到“report1”虚拟目录的驱动器上有数千个报告——每个都有自己的“img”目录——因此也没有合理的方法可以使用 IIS 管理器单独映射这些目录。
我正在寻找是否有某种方法可以在 IIS 服务器 web.config 文件中添加通配符(或其他)HttpRedirect 以正确映射所有报告的所有图像。我试过了:
<add wildcard="*res/img/" destination="/reporter/content/images/reportimages" />
但这似乎没有任何效果。
编辑:更多研究表明,使用 URL Rewrite 模块可能有效......但到目前为止我还没有让它工作。
我的规则如下所示(在 web.config 中):
<rules>
<rule name="Redirect rule1 for ImageRedirect">
<match url=".*" />
<conditions>
<add input="{ImageRedirect:{REQUEST_URI}}" matchType="Pattern" pattern="/res/img/(.+)" ignoreCase="true" negate="false" />
</conditions>
<action type="Redirect" url="{HTTP_HOST}/reporter/content/reporterimages/{C:1}" appendQueryString="false" />
</rule>
</rules>
【问题讨论】:
标签: url-rewriting web-config http-redirect url-rewrite-module iis-8