CodeIgniter Forums
isset($_SERVER['HTTPS']) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: isset($_SERVER['HTTPS']) (/showthread.php?tid=35623)



isset($_SERVER['HTTPS']) - El Forum - 11-05-2010

[eluser]theshiftexchange[/eluser]
Hi everyone,

I've recently started using the piece of code below to define my base url:

Code:
$config['base_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 'https://' : 'http://' ;
$config['base_url'] .= $_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME'])).'/';

My question is: where is $_SERVER['HTTPS'] defined?


isset($_SERVER['HTTPS']) - El Forum - 11-05-2010

[eluser]tonanbarbarian[/eluser]
as the name suggests all $_SERVER variables are provided by the webserver


isset($_SERVER['HTTPS']) - El Forum - 11-05-2010

[eluser]Shay Falador[/eluser]
The whole $_SERVER global-array is defined by PHP itself.
The HTTPS is defined and contains on if the page is accessed by https protocol (e.g. https://www.domain.com/ will set it on, http://www.domain.com/ won't).
You can read more about $_SERVER global-array in php.net web site.