title: Redirect to https using .htaccess
body: <p>I have a problem with .htaccess</p>
  
  <p>I have a certificate in my server, and it's only for <a href="https://example.com" rel="noreferrer">https://example.com</a> (not <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a>) Therefore, I'm trying to do a .htaccess redirect to the correct url.</p>
  
  <p>My intention is this:</p>
  
  <pre><code>http://www.example.com --&gt; https://example.com
  http://example.com --&gt; https://example.com
  https://www.example.com --&gt; https://example.com
  </code></pre>
  
  <p>I tried different combinations and nothing seems to work. At the moment I have this, but seems like is not working for</p>
  
  <p><code>http://www.example.com/subfolder</code>, I don't know what is failing...</p>
  
  <pre><code>RewriteEngine On
  
  # Follow symbolic links.
  Options +FollowSymLinks
  
  RewriteCond %{HTTP_HOST} !^$
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
  
  # Prevent directory listings
  Options All -Indexes
  </code></pre>