Exclude subdomain from HTTPS redirectRSS

3 replies

Last post Jan 08, 2020 01:22 AM by Jalpa Panchal

  • Exclude subdomain from HTTPS redirect

    Jan 06, 2020 12:38 PM|ClausRonnow|LINK

    I need to exclude a specific subdomain (sub.domain.com) from the REDIRECT TO HTTPS rule in the web.config below. How do I do that?

    <rules>
    <rule name="www" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^www." negate="true" />
    </conditions>
    <action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
    </rule>
    <rule name="Redirect to https" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
    </rule>
    </rules>

  • Re: Exclude subdomain from HTTPS redirect

    Jan 07, 2020 02:49 AM|Jalpa Panchal|LINK

    Hi,

    You could use the below rule to do no redirect subdomain to https.

    <rule name="exclude subdomain https" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll">
    <add input="{HTTPS}" pattern="off" />
    <add input="{HTTP_HOST}" pattern="^sub\.domain\.com$" negate="true" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
    </rule>

    Regards,

    Jalpa

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: Exclude subdomain from HTTPS redirect

    Jan 07, 2020 10:05 AM|ClausRonnow|LINK

    Hi Jalpa,

    I have tried to include your rule with the two existing rules, but the sub domain is still redirected to https:// ...

    Should I ONLY use your rule and not the two existing rules?

    Best regards,

    Claus

  • Re: Exclude subdomain from HTTPS redirect

    Jan 08, 2020 01:22 AM|Jalpa Panchal|LINK

    Yes, this is happening because of the 2nd rule "Redirect to https". try to disable this rule. 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.