Check if HTTP or HTTPS is used

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ecce
Forum Newbie
Posts: 5
Joined: Tue Apr 25, 2006 4:16 am

Check if HTTP or HTTPS is used

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

http://be2.php.net/reserved.variables
'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.
ecce
Forum Newbie
Posts: 5
Joined: Tue Apr 25, 2006 4:16 am

Post by ecce »

Thanks, worked fine!

A little wierd that it's not documented other that in the comments on php.net
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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)
Post Reply