note 100877 deleted from reserved.variables.server by cmb
| From: | cmb@php.net | Date: | Sun, 24 Mar 2019 11:21:07 +0000 |
| Subject: | note 100877 deleted from reserved.variables.server by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-210442@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Use Strict-Transport-Security (STS) to force the use of SSL.
<?php
$use_sts = TRUE;
if ($use_sts && isset($_SERVER['HTTPS']) {
header('Strict-Transport-Security: max-age=500');
} elseif ($use_sts && !isset($_SERVER['HTTPS']) {
header('Status-Code: 301');
header('Location: https://'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI']);
}
?>