PHP: HTTP or HTTPS? How can one tell?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elijahparker
    New Member
    • May 2006
    • 4

    PHP: HTTP or HTTPS? How can one tell?

    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_PROTOCO L']; ?>[/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

    Elijah and Jackie are Professional Wedding Photographers servicing the Minneapolis, Saint Paul, and Twin Cities areas of Minnesota, and are also ready to travel for Destination Weddings or wherever your event takes place. Specializing in Wedding Photography, Engagements, Bridal and Portrait Photography for Families, Kids, and Senior/Grad Pictures.
  • elijahparker
    New Member
    • May 2006
    • 4

    #2
    I found it!

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

    Elijah

    Comment

    • genepeng
      New Member
      • Apr 2008
      • 1

      #3
      Originally posted by elijahparker
      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.

      Comment

      Working...