I'm trying to implmenet a scenerio where my website's images are stored in an Amazon S3 bucket. So far, i've setup the bucket and the CNAME record so that images are correctly served from S3 via the URI pattern: 'http://images/myDomain.com/[image files]'
Now I want to convince IIS to rewrite incoming requests to point to S3. The site's images are currently stored as:
http://testing.myDomain.com/content/images/logo.jpg.
Working off several samples for IIS's URL Rewrite module, this is the rule that I'm thinking should work but obviously isn't. Since I'm testing this, I literally am working in the subdomain named testing. The above URL really _does resolve to my logo.jpg.
<rule name="Redirect Images" stopProcessing="true">
<match url="http://testing.myDomain.com/content/images/(.*)" />
<action type="Redirect" url="http://images.myDomain.com/{R:0}" />
</rule>
mny thx
The match url field is just the url part, so it needs to be "content/images/(.*)". That should cause your rule to work.
Make sure to update your HTML source whenever possible to use the images.mydomain.com path. Then the client-side redirect doesn't need to be performed and the URL Rewrite rule is just a backup for old leftover links.
You can also consider ARR as a reverse proxy so that there isn't a client-side redirect when an image is called.