title: How to redirect HTTPS non-www to HTTPS www using .htaccess?
body: <p>When I visit my site at <a href="https://example.com" rel="noreferrer">https://example.com</a>, my browser responds with ERR_CONNECTION_REFUSED. Note that the following all work:</p>
  
  <ul>
  <li><a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li>
  <li><a href="http://example.com" rel="noreferrer">http://example.com</a> redirects to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li>
  <li><a href="http://www.example.com" rel="noreferrer">http://www.example.com</a> redirects to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a></li>
  </ul>
  
  <p>How can I redirect <a href="https://example.com" rel="noreferrer">https://example.com</a> requests to <a href="https://www.example.com" rel="noreferrer">https://www.example.com</a> using .htaccess?</p>
  
  <p>I've tried the following which doesn't seem to work:</p>
  
  <pre><code>// .htaccess
  
  RewriteEngine On
  RewriteCond %{HTTPS} on
  RewriteCond %{HTTP_HOST} !^www\. [NC]    
  RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301] 
  </code></pre>