locked
exclude subdomain from rewrite RRS feed

  • Question

  • User987320842 posted

    hello

    i created rule to redirect non-www to www

    <rule name="CanonicalHostNameRule1" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^www\.mysite\.com$" negate="true" />
                        </conditions>
                        <action type="Redirect" url="http://www.mysite.com/{R:1}" />
                    </rule>

     

    how exclude from this rule subdomain  httpS://SECURE.mysite.com

     thanks!!!

    Thursday, November 4, 2010 2:18 PM

Answers

  • User-322036075 posted

    It is all phonetics, you just need to read them out loud to follow them.

     You need to remove the negate=true. This says if a user browses a site using HTTP and the domain is secure.mysite.com, then redirect to https://secure.mysite.com/<URI>

     <rule name="Force FQDN on HTTPS" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTPS}" pattern="off" />
                            <add input="{HTTP_HOST}" pattern"^secure\.mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="https://secure.mysite.com/{R:1}" />
                    </rule>

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, November 10, 2010 2:24 PM

All replies

  • User-322036075 posted

    Here you go,

    <rule name="CanonicalHostNameRule1" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^(www|secure)\.mysite\.com$" negate="true" />
                        </conditions>
                        <action type="Redirect" url="http://www.mysite.com/{R:1}" />
                    </rule>

    Then make another rule after this one to force HTTPS on secure.

     <rule name="Force FQDN on HTTPS" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTPS}" pattern="off" />
                            <add input="{HTTP_HOST}" pattern"^secure\.mysite\.com$" negate="true" />
                        </conditions>
                        <action type="Redirect" url="https://secure.mysite.com/{R:1}" />
                    </rule>

     

    Friday, November 5, 2010 10:16 AM
  • User987320842 posted

    <add input="{HTTP_HOST}" pattern"^secure\.mysite\.com$" negate="true" />
    in this string some error

    Monday, November 8, 2010 4:12 PM
  • User-322036075 posted

    forgot the = equal sign.

    <add input="{HTTP_HOST}" pattern="^secure\.mysite\.com$" negate="true" />

     

    Monday, November 8, 2010 4:33 PM
  • User987320842 posted

    now when i did enter mysite.com - i redirected to secure.mysite.com

    Monday, November 8, 2010 4:40 PM
  • User-322036075 posted

    more typos.

     Remove this from the https

    The should be If HTTPS is off and the HTTP_HOST is secure.mysite.com and redirect to https://secure.mysite.com

      <add input="{HTTP_HOST}" pattern"^secure\.mysite\.com$" negate="true" />

    I was cutting and pasting from previous rules, sorry about that.

     

    Monday, November 8, 2010 7:24 PM
  • User987320842 posted

    sory - i dont understand you - what i should delete and from? do you can provide me full code?

    Wednesday, November 10, 2010 1:25 PM
  • User-322036075 posted

    It is all phonetics, you just need to read them out loud to follow them.

     You need to remove the negate=true. This says if a user browses a site using HTTP and the domain is secure.mysite.com, then redirect to https://secure.mysite.com/<URI>

     <rule name="Force FQDN on HTTPS" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTPS}" pattern="off" />
                            <add input="{HTTP_HOST}" pattern"^secure\.mysite\.com$" />
                        </conditions>
                        <action type="Redirect" url="https://secure.mysite.com/{R:1}" />
                    </rule>

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, November 10, 2010 2:24 PM