0
votes

I am trying to redirect/redirect and pass all http-only (non-secure) image urls through a local https proxy hosted on my domain (using Url Rewrite in IIS 8.5). The source does not provide https so this is my only solution (as far as I know). Here is my code and its not working. Kindly help:

<rule name="assets redirection" stopProcessing="false">
        <match url="^(.*)\.example-differnt-domain\.com" ignoreCase="false" />
        <action type="Redirect" url="https://example.COM/p/?url={HTTP_HOST}/{R:0}" 
        appendQueryString="true" redirectType="Permanent" />
</rule> 

It does not seem to be doing anything. Source images urls are in the following format

http://subdomain1.subdomain2.example-different-domain.com/xyz/abc/lmnop.jpg

There could be other image types too

I want to rewrite the url so that it looks like this: https://example.COM/p/?url=http://subdomain1.subdomain2.example-different-domain.com/xyz/abc/lmnop.jpg

Unfortunately, my regex is not really good and i am wondering I am might be doing something wrong with the pattern matching.

Any help is appreciated in this regard.

1

1 Answers

0
votes

The url attribute in the match node only matches the path, not the domain. In order to match the host you will need to use the HTTP_HOST server variable. This section of the rewrite rule documentation give a good explanation of this. There are a couple of examples as well on that page that use HTTP_HOST which seems similar to what you are trying to achieve.