title: .htaccess file not redirecting http://www. to https://www
body: <p>I have made a .htaccess file to redirect all website traffic to <code>https://www.</code>.</p>
  
  <p><strong>This is my complete .htaccess file:</strong></p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
  RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  </code></pre>
  
  <p>The below redirects work exactly as expected:</p>
  
  <pre><code>http://example.com -&gt; https://www.example.com
  https://example.com -&gt; https://www.example.com
  https://www.example.com -&gt; https://www.example.com
  </code></pre>
  
  <p><strong>Except:</strong></p>
  
  <pre><code>http://www.example.com -&gt; http://www.example.com
  </code></pre>
  
  <p>As shown above, if you go to <code>http://www.</code> it doesn't redirect to the HTTPS version.</p>
  
  <p>Can anyone help me understand why the other redirects are working fine, but that one is not?</p>
  
  <p>Additional Notes: <em>I have looked at a number of posts on StackOverflow, but most of their solutions end in redirect loop errors.</em></p>