title: What is the best practice for auto switching from HTTP to HTTPS
body: <p>I'm curious. What is the best practice to auto switch the user from <a href="http://www.example.com" rel="nofollow noreferrer">http://www.example.com</a> to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a></p>
  
  <p>i.e. from <em>http</em> to <em>https</em>? Ideally I would like to make it so that no matter what the url (and any possible get data)</p>
  
  <p>There are a couple things people chat about like checking <code>$_SERVER ["SERVER_PROTOCOL"]</code> or <code>$_SERVER['SERVER_PORT']</code> or <code>$_SERVER['HTTPS']</code> but I would like to know what the best practice is.</p>