RE: [PHP] Finding out whether request was done via http or https
| From: | Ernest E Vogelsinger | Date: | Fri, 23 May 2003 12:13:20 +0000 |
| Subject: | RE: [PHP] Finding out whether request was done via http or https | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-148764@lists.php.net to get a copy of this message | ||
At 23:54 23.05.2003, Mohit Mittal said:
--------------------[snip]--------------------
>if($_SERVER["SERVER_PORT"] == 80) {
> // request is made through http
> }
>else{
> //ELSE request is made through https
> }
>
>The default port for https is 443.
--------------------[snip]--------------------
What if the server sits on a different port?
At least with my PHP version (4.2.3) there is an additional entry in the
$_SERVER array "HTTPS" which one can use:
if (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS']) {
// request is made through HTTPS
}
else {
// request is made through HTTP
}
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/