364,088 Members | 5483 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

PHP: HTTP or HTTPS? How can one tell?

elijahparker
P: 4
How can I tell if a php page was accessed via http or https?

I already tried this seemingly simple solution, but for me it does not work. How can this be? Any ideas?

[PHP]<?php echo $_SERVER['SERVER_PROTOCOL']; ?>[/PHP]


simply returns:

HTTP/1.1

Whether the page is accessed via http or https.

I never realized this little thing could be such a challange! Any ideas would be greatly appreciated. Thanks!

Elijah

http://www.elijahparker.com
May 7 '06 #1
Share this Question
Share on Google+
2 Replies


elijahparker
P: 4
I found it!

[PHP]if($_SERVER['HTTPS'] == on)[/PHP]

Elijah
May 7 '06 #2

genepeng
P: 1
I found it!

[PHP]if($_SERVER['HTTPS'] == on)[/PHP]

Elijah
Name-based virtual hosting cannot be used with SSL secure servers because of the nature of the SSL protocol. if you config your apache base on Name-based(More than one web site per IP address), this solution doesn't work.
Apr 22 '08 #3

Post your reply

Help answer this question



Didn't find the answer to your PHP question?

You can also browse similar questions: PHP