How to find http portion of a URL?

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
User avatar
uberdragon
Forum Newbie
Posts: 11
Joined: Thu Apr 27, 2006 8:54 am
Location: Farmington, CT

How to find http portion of a URL?

Post by uberdragon »

Hi everyone,

I want to force a section of a web page to use SSL. In otherwords I was going to header push someone that was visiting http://www.domain.com/checkout.php to https://www.domain.com/checkout.php

I can't seem to find a way to read that part of the url from a PHP environment variable to determine if the script was accessed behind the certificate protected url (https) or not (http)... Any suggestions?

~Uber
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The information is held in $_SERVER in the HTTPS element. If the element is present and not "off" you're in a secured connection.
User avatar
uberdragon
Forum Newbie
Posts: 11
Joined: Thu Apr 27, 2006 8:54 am
Location: Farmington, CT

Post by uberdragon »

feyd wrote:The information is held in $_SERVER in the HTTPS element. If the element is present and not "off" you're in a secured connection.
Perfect! Thanks I don't know how I over looked it lol

~Uber
Post Reply