title: Forcing SSL and WWW using .htaccess
body: <p>I would like to know if this code in <code>.htaccess</code> for forcing SSL and WWW in URL is correct, because with another codes I usually get redirect loop, e.g. <code>RewriteCond %{HTTPS} !=on</code> and now it works like a charm (suspiciously). Also, is possible to write it better/simplier?</p>
  
  <pre><code># Force to SSL
  RewriteCond %{HTTP:HTTPS} !1
  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
  
  # Force to WWW
  RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
  RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]  
  </code></pre>