Posted By

StevenW721 on 07/09/10


Tagged

ssl


Versions (?)

Force SSL usage


 / Published in: PHP
 

  1. function forceSSL ()
  2. { // force SSL usage and use of WWW
  3. if (($_SERVER["SERVER_PORT"] != 443)) {
  4. header("Location: " . "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]);
  5. exit();
  6. }
  7. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: shaunduncan on July 13, 2010

You can also use the 'HTTPS' server variable for cases where SSL may not be serviced by the default port 443: if($_SERVER['HTTPS'] == 'off')

You need to login to post a comment.