Url rewriting IIS 8.0目录HttpRedirect

Url rewriting IIS 8.0目录HttpRedirect,url-rewriting,web-config,http-redirect,url-rewrite-module,iis-8,Url Rewriting,Web Config,Http Redirect,Url Rewrite Module,Iis 8,IIS中是否有重定向以下请求的方法: http://mysite/report1/img/logo.png至http://mysite/myapplication/report1/images/logo.png对于img目录中的所有图像,无需单独显式映射它们 附加要求-我在一个映射到“report1”虚拟目录的驱动器上有数千个报告-每个报告都有自己的“img”目录-因此也没有合理的方法使用IIS管理器单独映射这些目录 我想看看是否有办法在IIS服务器web.config文件中添加通配符(或其他)

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重写模块可能会起作用。。。但到目前为止,我还没有让它发挥作用

我的规则如下(在web.config中):


您使用URL重写模块的方法是正确的。
在您的情况下,最简单的规则是:

<rule name="Rewrite images" stopProcessing="true">
  <match url="^/report1/img/(.+)$" />
  <action type="Rewrite" url="/myapplication/report1/images/{R:1}" />
</rule>

(如果您没有指定,默认情况下重定向是永久的(301))

谢谢您的回复!但我似乎无法让它发挥作用。这是一个真正的输入url:
http://localhost/atlas/report-1.0.2/res/img/ctc.png
和重定向url:
http://localhost/reporter/content/images/reportimages/ctc.png
。好像什么都没有发生……您是否已将正则表达式更改为
url=“^atlas/report-1.0.2/res/img/(.+)$”
?您使用过重写或重定向版本吗?我没有更改正则表达式,因为url的report-1.0.2部分将更改。url中唯一一致的部分是主机(
http://localhost
)和
/res/img/
。我想我只需要将匹配更改为“/res/img/(.+)$”而不是开始(^)。它似乎适用于一个特定的图像url,但不适用于嵌入在页面中的图像url。。。还在努力!好的,这是有道理的。请注意,重定向和重写是两种完全不同的操作。如果你仍然有问题,用你的规则和错误更新你的问题,我会看一看。
<rule name="Rewrite images" stopProcessing="true">
  <match url="^/report1/img/(.+)$" />
  <action type="Rewrite" url="/myapplication/report1/images/{R:1}" />
</rule>
<rule name="Redirect images" stopProcessing="true">
  <match url="^/report1/img/(.+)$" />
  <action type="Redirect" url="/myapplication/report1/images/{R:1}" />
</rule>