PHP Auto Direct from HTTP to HTTPS

From Notes

Jump to: navigation, search

The following PHP code will direct non-ssl requests to ssl versions of the same request:

<?php 
  // Require SSL
  if($_SERVER['HTTPS'] != 'on') {
    header("Location: https://" . $_SERVER['HTTP_HOST'] . "/" . $_SERVER['REQUEST_URI']) ;
  }
?>
Personal tools