title: Host Angular app on IIS - Redirect to root and force HTTPS
body: <p>I have got an angular application hosted in IIS. In order to redirect all the requests to the root of the application and to allow angular routing to deal with the different routes, I have added a web.config file with a URL Rewrite rule, as follows:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;system.webServer&gt;
    &lt;rewrite&gt;
      &lt;rules&gt;
       &lt;rule name="Angular Routes" stopProcessing="true"&gt;
           &lt;match url=".*" /&gt;
         &lt;conditions logicalGrouping="MatchAll"&gt;
           &lt;add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /&gt;
          &lt;add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /&gt;
         &lt;/conditions&gt;
         &lt;action type="Rewrite" url="/" /&gt;
       &lt;/rule&gt;
    &lt;/rules&gt;
   &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>It works fine. However, I need now to force the application to redirect from HTTP to HTTPS. In order to do that I can add a new rule as the following post depicts: <a href="https://stackoverflow.com/questions/38334894/angular-2-always-redirect-to-https-instead-of-using-http">Angular 2 - always redirect to https:// instead of using http://
  </a></p>
  
  <p>Rule to force HTTPS:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;system.webServer&gt;
      &lt;rewrite&gt;
          &lt;rules&gt;
              &lt;clear /&gt;
              &lt;rule name="Redirect to https" stopProcessing="true"&gt;
                  &lt;match url="(.*)" /&gt;
                  &lt;conditions&gt;
                      &lt;add input="{HTTPS}" pattern="off" ignoreCase="true" /&gt;
                  &lt;/conditions&gt;
                  &lt;action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /&gt;
              &lt;/rule&gt;
          &lt;/rules&gt;
      &lt;/rewrite&gt;
  &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>This rule works as well, but It breaks my redirect to root rule defined previously. So Does anybody have an idea How can I mix these two rules together or which other way I can achieve both purposes?</p>