Re: checking for and enforcing https
| From: | Daniel Brown | Date: | Mon, 25 Feb 2008 19:09:19 +0000 |
| Subject: | Re: checking for and enforcing https | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-270108@lists.php.net to get a copy of this message | ||
On Mon, Feb 25, 2008 at 1:40 PM, Rick Pasotto <rick@niof.net> wrote:
> What is the best or recomended proceedure for making sure that a page is
> accessed only via a secure connection?
Provided you're running SSL on the standard HTTPS port of 443,
include this at the very top of every file, before any output or
session information is sent. The best option would be to include it
in a file in a switched index.php or similar design.
<?
if($_SERVER['SERVER_PORT'] != '443') {
$url = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] :
$_SERVER['SERVER_NAME'];
header("Location:
https://".$url.$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']);
exit;
}
?>
--
</Dan>
Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>