title: Force HTTPS too many redirect with .htaccess, how to resolve?
body: <p>I know this has been asked and answered several times and I have gone through a lot of them but still have not solved my issue.</p>
  
  <p>I have the following code in my <code>.htaccess</code> file.</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{ENV:HTTPS} !=on
  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  </code></pre>
  
  <p>I want to redirect all of the following:</p>
  
  <ul>
  <li><code>http://www.example.com</code></li>
  <li><code>http://example.com</code></li>
  <li><code>https://example.com</code></li>
  </ul>
  
  <p>to redirect to <code>https://www.example.com</code>.</p>
  
  <p>Currently it comes up to an error page stating too many redirects, I have tried clearing cookies to no avail.</p>
  
  <p>What am I doing wrong and how can I make it work?</p>