简体   繁体   中英

IIS Redirects for both HTTPS and HTTP

I am trying to setup a redirect that will detect if https is used and redirect traffic to https://example.com.au and if http is used redirect traffic to http://123.com.au .

I'm currently using IIS Rewrite.

I've tried doing a few things but it isn't working.

You can do that with these rules:

<rule name="Redirect with HTTPS" stopProcessing="true">
    <match url="(.*)" />
    <conditions><add input="{HTTPS}" pattern="^ON$" />
    </conditions>
    <action type="Redirect" url="https://example.com.au/{R:1}" />
</rule>
<rule name="Redirect without HTTPS" stopProcessing="true">
    <match url="(.*)" />
    <conditions><add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="http://123.com.au/{R:1}" />
</rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM