title: Forcing HTTPS on expression engine redirect loop
body: <p>I'm trying to force HTTPS using the .htaccess of a site running expression engine.
  As of right now you are able to go to the site using https:// but when i add any of these rules it presents a redirect loop.</p>
  
  <pre><code>RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  </code></pre>
  
  <p>or</p>
  
  <pre><code>RewriteCond %{SERVER_PORT} !^443$
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
  </code></pre>
  
  <p>or</p>
  
  <pre><code>RewriteCond %{SERVER_PORT} 80
  RewriteRule ^(.*)$ https://mydomain.com/$1 [R,L]
  </code></pre>
  
  <p>and also  this fancy one</p>
  
  <pre><code>RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  </code></pre>
  
  <p>and I've also tried rearranging all the rules on each of them so I'm pretty sure it has something to do with the conditions matching when they shouldn't.</p>
  
  <p>I've also read some things about load balancers redirecting things counter to the .htaccess
  from here:
  <a href="https://stackoverflow.com/questions/18647302/htaccess-redirect-loop-when-trying-to-add-forced-https-rule-amazon-elastic-bea">.htaccess redirect loop when trying to add forced HTTPS rule (Amazon Elastic Beanstalk)</a> and here: <a href="https://serverfault.com/questions/283525/force-ssl-on-one-page-via-htaccess-without-looping">https://serverfault.com/questions/283525/force-ssl-on-one-page-via-htaccess-without-looping</a></p>
  
  <p>i think my client is using inmotion hosting but I don't have access to the load balancer settings so I want to make sure that is the problem.</p>
  
  <p>here is the entire htaccess. I removed some of the default expression engine stuff, but it was also not working before I did that.</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  # Enable Rewrite Engine
  # ------------------------------
  RewriteEngine On
  RewriteBase /
  
  # RewriteCond %{HTTPS} off
  # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
  
  # RewriteCond %{HTTP:X-Forwarded-Proto} !https
  # RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
  
  # Redirect index.php Requests
  # ------------------------------
  RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
  RewriteCond %{THE_REQUEST} ^GET
  RewriteRule ^index\.php(.+) $1 [R=301,L]
  
  # Standard ExpressionEngine Rewrite
  # ------------------------------
  RewriteCond $1 !\.(css|js|images|gif|jpe?g|png) [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>(I have them disabled because the site is live)</p>