note 83146 deleted from function.header by nlopess
| From: | nlopess@php.net | Date: | Mon, 26 May 2008 14:48:43 +0000 |
| Subject: | note 83146 deleted from function.header by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-139795@lists.php.net to get a copy of this message | ||
Note Submitter: stevenwebster at gmail dot com
----
These functions turn on SSL, and turn off SSL.
<?php
//This works in 5.2.3
//First function turns SSL on if it is off.
//Second function detects if SSL is on, if it is, turns it off.
//You must use these functions before the </head> tag in order for them to work.
//==== Turn on HTTPS - Detect if HTTPS, if not on, then turn on HTTPS:
function SSLon{
if($_SERVER['HTTPS'] != 'on'){
header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}
}
//==== End -- Turn On HTTPS
//==== Turn Off HTTPS -- Detect if HTTPS, if so, then turn off HTTPS:
function SSLoff{
if($_SERVER['HTTPS'] == 'on'){
header("Location: http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
}
}
//==== End -- Turn Off HTTPS
?>