title: I want to redirect all traffic to HTTPS and WWW at the same time
body: <p>What I currently have is</p>
  <pre><code>RewriteEngine On
  RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  </code></pre>
  <p>This code redirectly only to HTTPS  but not also from non Www to www</p>
  <pre><code># Canonical https/www
  &lt;IfModule mod_rewrite.c&gt;
      RewriteCond %{HTTPS} off [OR]
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteCond %{HTTP_HOST} ^(.*)$  [NC]
      RewriteRule (.*) https://www.%1/$1 [R=301,L]
  &lt;/IfModule&gt;
  </code></pre>
  <p>I tried this code before</p>
  <p>and I start getting urls like <code>https://www.www.example.com</code>  which is a disaster....</p>
  <p>is there a proper code to do both at the same time HTTPS and WWW redirect?</p>