title: Rerouting all http traffic to https with AWS ELB
body: <p>So I've looked over the other similar questions and they offer solutions but none of them seem to work for some reason. So, for starters, my ELB is set up so that</p>
  
  <pre><code>HTTP (incoming) -&gt; HTTP (instance)
  HTTPS (incoming) -&gt; HTTP (instance)
  </code></pre>
  
  <p>So both traffic should come in on port 80. And this works, as when I access my site using <a href="http://mydomain.com">http://mydomain.com</a> or <a href="https://mydomain.com">https://mydomain.com</a>, it is able to display even though I only have a VirtualHost for on port 80.</p>
  
  <p>The issue is with attempting to rewrite all http traffic to https. I use to do it based on ports (check if !443 and rewrite to https) but that won't work now that everything is going into 80. So I'm running an Apache server and have this rewrite rule</p>
  
  <pre><code>RewriteEngine on
  RewriteCond %{HTTP_HOST} www.(.+) [OR,NC]    # Added
  RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
  RewriteRule ^/?(.*) https://mydomain.com%{REQUEST_URI} [L,R=301]
  </code></pre>
  
  <p>But it never seems to work. Are there other lines I'm missing? Is there a way to check that it's hitting that condition? I tried both <em>!https</em> and <em>http</em> as the condition and neither worked.</p>
  
  <p><strong>edit:</strong> Slightly changed my RewriteRule to what it is now and it's still not working. I added an extra condition to rewrite www and that <strong>works</strong>. HTTP:X-Forwarded-Proto either isn't there or isn't set by the load balancer</p>
  
  <p><strong>edit:</strong> The mistake was REALLY dumb. I was simply SSHing into the wrong instance. Thanks for putting up with my foolishness</p>