<?php

/* Redirect to HTTPS and refuse to serve HTTP */
if($_SERVER['HTTPS'] != "on"){
  $_SERVER['FULL_URL'] = 'https://';
  if($_SERVER['SERVER_PORT']!='80')
    $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
  else
    $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
  if($_SERVER['QUERY_STRING']>' '){
    $_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];
  }

  header("Location: " . $_SERVER['FULL_URL'], true, 301);
  exit();
} else {
  /* Only use HTTPS for the next year */
  header("Strict-Transport-Security: max-age=31536000");
}

?>

<?php

/* Redirect to HTTPS and refuse to serve HTTP */
if($_SERVER['HTTPS'] != "on"){
  $_SERVER['FULL_URL'] = 'https://';
  if($_SERVER['SERVER_PORT']!='80')
    $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
  else
    $_SERVER['FULL_URL'] .=  $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
  if($_SERVER['QUERY_STRING']>' '){
    $_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];
  }

  header("Location: " . $_SERVER['FULL_URL']);
  exit();
} else {
  /* Only use HTTPS for the next year */
  header("Strict-Transport-Security: max-age=31536000");
}

?>

--- 
+++ 
@@ -11,7 +11,7 @@
     $_SERVER['FULL_URL'] .=  '?'.$_SERVER['QUERY_STRING'];
   }
 
-  header("Location: " . $_SERVER['FULL_URL']);
+  header("Location: " . $_SERVER['FULL_URL'], true, 301);
   exit();
 } else {
   /* Only use HTTPS for the next year */
Convert HTTP redirect to 301 Moved Permanently

When issuing a redirect, make it a Permanent one so we can give the browser
another indicator that this change is permanent and it should not try to use
HTTP again for this resource.
