title: Doing a redirect from naked http & https domain to https://www domain in htaccess?
body: <p>this solution <a href="https://stackoverflow.com/questions/25092323/http-domain-to-https-www-in-one-redirect">http://domain to https://www in one redirect</a></p>
  
  <p>Doesnt seem to work for me. I'd like to have..(same as OP) </p>
  
  <pre><code>http://example.com
  http://www.example.com
  https://example.com
  </code></pre>
  
  <p>all to redirect to <code>https://www.example.com</code></p>
  
  <p>I've tried a number of solutions and nothing seems to work.</p>
  
  <p>Details:</p>
  
  <p>-I have an ssl installed for the <code>www.example.com</code> version of the site.
  -Running wordpress
  -tried ssl plugins and nothing works
  -tried the following htaccess rules, the first doesnt seem to do anything, the second caused an infinite loop</p>
  
  <pre><code>RewriteCond %{HTTP_HOST} !^$
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTPS} off
  RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
  </code></pre>
  
  <p>and the second try...</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{SERVER_PORT} !=443
  RewriteCond %{HTTP_HOST} ^(www\.)?your domain name\.com$ [NC]
  RewriteRule ^$ https://www.your domain name.com/%{REQUEST_URI} [R,L]
  </code></pre>
  
  <p>this one caused a loop..</p>
  
  <p>I'm starting to think that my approach is wrong. Shouldn't one of these work? And if not, how do i go about securing this site completely on the www subdomain</p>