IIS/web.config Redirect folder to another host but not its sub directoy
I have a two servers, one is for development and the other is for production.
My local environment's database is often refreshed so that the data that appears on my local environment becomes an exact mirror of the pr开发者_StackOverflow社区oduction server. However the images which are referenced in that database are not because the image library is far too large.
Is it possible for me to redirect images to the images directory on the production server but exclude any subfolders within the directory from being redirected.
I need to be able to do this either using web.config or by IIS.
For example:
localhost/images/file.jpg | .gif | .png
to redirect to
productionserver/images/file.jpg | .gif | .png
but exclude
localhost/images/assets/
Yes you just need to get your regex right:
<rules>
<rule name="image redirect" stopProcessing="true">
<match url="^images/([^/]*)$" />
<action type="Redirect" url="productionserver/images/{R:1}" />
</rule>
</rules>
精彩评论