We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

simple question  [Answered]RSS

2 replies

Last post Feb 21, 2020 01:56 PM by sbsmithjax

  • simple question

    Feb 20, 2020 04:11 PM|sbsmithjax|LINK

    I continue to find this elegant iis snippet a real help from here: https://caduceus.me/2HDpWha which provide www removal, https rewrite of all domains, pointing to your main webiste. I have a question, I'm wondering if someone could share any insight. I'm on win2016 server, IIS10

    I've been using the refactored version from above, to redirect all of my 'extra' domains (my .nets, .orgs, slight mispellings, etc, to my main https://geriatricspt.org works perfectly.

    What if I needed now, to have one particular 'extra' domain, be exempted from this process, and have that one directed specifically to a subfolder of the main site.

    I've tried this:


    <rule name="forward gerinotes.org" patternsyntax="ExactMatch" stopprocessing="true">

    <match url="*"/>


    <add input="{HTTP_HOST}" pattern="gerinotes.org"/>


    <action type="Rewrite" url="https://geriatricspt.org/members/publications/gerinotes/"/>


    <rule name="Redirect everything to https://geriatricspt.org" patternsyntax="Wildcard" stopprocessing="true">

    <match url="*"/>

    <conditions logicalgrouping="MatchAny">

    <add input="{HTTP_HOST}" pattern="geriatricspt.org" negate="true"/>

    <add input="{HTTPS}" pattern="off" ignorecase="true"/>


    <action type="Redirect" url="https://geriatricspt.org/{R:0}"/>




    Thinking that the first rule would be processed, redirected to that subfolder, and then processing of rules would stop. But that is not what is happening. Instead, the lower rule takes over and everything lands at https://geriatrictspt.org . If you remove the lower rule, the top rule works perfectly.

    Any advice is super helpful.


  • Rovastar Rovastar

    5495 Posts



    Re: simple question

    Feb 20, 2020 07:09 PM|Rovastar|LINK

    It looks like your first rule is a rewrite and not a redirect therefore the host name will be the same and is caught in the second rule. That is way out of processed.

    Check that with failed request tracing to see what is happening.

    Also it puts a little confusing as you are using different syntax types. I'm only really used to the regular expressions method.

    Troubleshoot IIS in style
  • Re: simple question

    Feb 21, 2020 01:56 PM|sbsmithjax|LINK

    OK, for those that might stumble upon this issue.  The problem here was a CLOUDFLARE proxy issue.  Because we had cloudflare engaged on this domain,  the redirects were not working.  

      The above two iis url rewrite rules worked great, as soon as we removed the cloudflare involvement.