title: IIS 8.5 URL Rewrite force redirect http --> https for non www
body: <p>I am starting with the rewrite module have a problem with a "simple" IIS 8.5 URL Rewrite redirect http --> https for a non www site. </p>
  
  <p>Problem: If the domain matches the action url parameter i always get "http://" and not "https://".</p>
  
  <p>This is my rule:</p>
  
  <pre><code>&lt;rewrite&gt;
    &lt;rules&gt;
      &lt;rule name="Redirect to HTTPS" stopProcessing="true"&gt;
        &lt;match url="(.*)" /&gt;
        &lt;conditions&gt;
          &lt;add input="{HTTPS}" pattern="^OFF$" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /&gt;
      &lt;/rule&gt;
    &lt;/rules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>I can't post several links so "domain" = crm.test.com. The site with the rewrite rule is bound to "domain"=crm.test.com on port 2080.</p>
  
  <p>I want to redirect "http://" to "http<strong>s</strong>://", but i always get "http://" as location in response:</p>
  
  <pre><code>   HTTP/1.1·302·Redirect
     Connection:·close
     Content-Length:·176
     Date:·Thu,·15·Jan·2015·08:21:21·GMT
     Location:·http://domain/                      &lt;--
     Content-Type:·text/html;·charset=UTF-8
     Server:·Microsoft-IIS/8.5
     X-Powered-By:·ASP.NET
  </code></pre>
  
  <p>I tried the following action url parameter:</p>
  
  <p>Not working:</p>
  
  <pre><code>"https://{HTTP_HOST}/{R:1}" -&gt; http://domain/
  "https://domain/{R:1}" -&gt; http://domain/
  "https://{HTTP_HOST}:443/{R:1}" -&gt; http://domain/
  "https://{HTTP_HOST}/1" -&gt; http://domain/1/
  </code></pre>
  
  <p>Working:</p>
  
  <pre><code>"https1://{HTTP_HOST}/{R:1}" -&gt; https1://domain/
  "https://{HTTP_HOST}:444/{R:1}" -&gt; https://domain:444/
  "https://test.domain.com/{R:1}" -&gt; https://test.domain.com/
  "https://www.google.com/{R:1}" -&gt; https://www.google.com/
  </code></pre>
  
  <p>I found "<a href="https://stackoverflow.com/questions/13028223/url-rewrite-on-iis-from-http-to-https-is-not-working">URL Rewrite on IIS from http to https is not working,</a>", but this doesn't solve my problem.</p>
  
  <p>Did i missed something?</p>