Page 1 of 1

Check if HTTP or HTTPS is used

Posted: Tue Apr 25, 2006 4:27 am
by ecce
This forum seems to have potential, so here comes the first post for me! :)

I need to check if a certain page loads via HTTP och HTTPS. I have not found a way to do this. Is there no way to get the complete request e.g. "http://www.yadayada.com/folder/index.php", and not just "/folder/index.php"? That way I could substr() the seven first caracters.

The $_SERVER['SERVER_PROTOCOL'] variable seems to be 'HTTP/1.1' even if HTTPS is used.

Posted: Tue Apr 25, 2006 6:05 am
by timvw
http://be2.php.net/reserved.variables
'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.

Posted: Tue Apr 25, 2006 6:56 am
by ecce
Thanks, worked fine!

A little wierd that it's not documented other that in the comments on php.net

Posted: Tue Apr 25, 2006 11:51 am
by timvw
The link i provided you was a link to their documentation... So that's pretty well documented ;) (You just have to know where it is)