title: Mod Rewrite - Force HTTPS and Rewrite Variable?
body: <p>I am running on Heroku and have added Rewrite rules to clean up the URL and also force https. I am having a small issue when the url is rewritten from http to https and don't understand rewrite rules enough yet to figure out what I am doing wrong.</p>
  
  <p>Current .htaccess on Heroku</p>
  
  <pre><code>    RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ ?id=$1 [QSA]
      ##Force SSL 
      RewriteCond %{HTTP:X-Forwarded-Proto} !https
  </code></pre>
  
  <p>When I visit <a href="https://example.com/12345" rel="nofollow noreferrer">https://example.com/12345</a> everything works great.
  When I visit <a href="http://example.com/12345" rel="nofollow noreferrer">http://example.com/12345</a> the url is rewritten to <a href="https://example.com/12345?id=12345" rel="nofollow noreferrer">https://example.com/12345?id=12345</a></p>
  
  <p>I'd like http to rewrite to <a href="https://example.com/12345" rel="nofollow noreferrer">https://example.com/12345</a></p>
  
  <p>What am I missing? Thanks in advance!</p>