Site Loader

It took a whill to find it…

My goal was to redirect a specific url to https!
I have one IIS site that has multiple urls. The IIS site has two bindings types *:80 and *:443, and the 443 binding contains a certificate for www.site1.ext.
In the DNS I pointed multiple urls to that IIS site for example: www.site1.ext, sub.site1.ext, www.site2.ext. And only www.site1.ext must be redirected to HTTPS. You can do that with IIS url rewrite module.

All articles that I could find are redirecting ALL incoming requests to https. But that is not what I want. My goal was to redirect just one url from that site to HTTPS.

You can do that like this:

<rule name="www.domain.ext to HTTPS" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
        <add input="{HTTP_HOST}" pattern="www.domain.ext" />
    </conditions>
    <serverVariables>
    </serverVariables>
    <action type="Redirect" url="https://{HTTP_HOST}{URL}" />
</rule>

 

Sander

https://cubik.com.tw/ click to find out more