【发布时间】:2017-12-08 18:22:57
【问题描述】:
这是我一直在努力解决的一个问题。
我在 server I 中托管了一个地址为 www.mywebsite.com 的网站,但该网站的图像来自 server II(ip:1.2.3.4)所以如果有这样的请求作为 www.mywebsite.com/images/123.jpg 我想将它们重定向到图像服务器(Server II)。
我希望包含 (.*jpg.*) 正则表达式的请求将重定向到 Server II。
-
使用 Url rewrite 我添加了一条规则:
<rewrite> <rules> <rule name="Ignore images requests" enabled="true" stopProcessing="true"> <match url="(.*jpg.*)" /> <action type="Rewrite" url="https://www.petfinder.com/wp-content/uploads/2012/11/91615172-find-a-lump-on-cats-skin-632x475.jpg" /> </rule> </rules> </rewrite>
如您所见,它将请求重写为静态图像,我该如何定义它以转到 1.2.3.4/images/imagename.jpg?
如果我可以通过我的主机文件忽略包含 jpg 的请求,最好的解决方案是,有什么办法吗?
【问题讨论】:
-
您能否提供图片来源和目标网址的示例?它将帮助我为您创建适当的规则
-
@VictorLeontyev 我希望当 url 包含 jpg 时,它将请求重定向到原始服务器。例如,如果我有:
https://styleplace/UserFiles/Entities/TopBanners/top50161616_586.jpg -
并且可以通过这个网址在原始服务器中访问图像? :
https://1.2.3.4/UserFiles/Entities/TopBanners/top50161616_586.jpg -
@VictorLeontyev 是的