title: htaccess RewriteRule to https doesn't work combined with other rules
body: <p>I'm trying to set a few rules in my <code>.htaccess</code> to work in a specific way:</p>
  
  <ol>
  <li><p>Specific page redirections:</p>
  
  
  
  <pre class="lang-bash prettyprint-override"><code>RewriteRule "^web/site/mais$" https://www.main.com/front/for-you/insurance/ [R=301,L]
  </code></pre></li>
  <li><p>Home redirection</p>
  
  <pre class="lang-bash prettyprint-override"><code>RewriteRule ^$  https://www.forexample.com.br/for-you/ [R=301,L]
  RewriteRule ^/$  https://www.forexample.com.br/for-you/ [R=301,L]
  </code></pre></li>
  <li><p>HTTP to HTTPS and add www to the rest (this is what doesn't work), i tried many things:</p>
  
  <pre class="lang-bash prettyprint-override"><code>RewriteCond %{HTTP_HOST} !^www\.
  RewriteCond %{HTTPS} !^on$ [OR]
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  RewriteCond %{HTTP_HOST} ^www\.
  RewriteCond %{HTTPS} !^on$ [OR]
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  </code></pre></li>
  </ol>
  
  <p>Other way I tried forgotting the www rule (but doesn't work too):</p>
  
  <pre class="lang-bash prettyprint-override"><code>RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>The only way I found to combine is writting the general <code>https</code> and <code>www</code> rule in the <code>httpd.conf</code> and the other rules into the <code>.htaccess</code>, but this way I get two or more 301 redirects, bad business for SEO.</p>