Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If page invoked with https 1

Status
Not open for further replies.

joeschoe

Programmer
Joined
Jan 13, 2002
Messages
67
Location
IL
My server is set up that any php file can be invoked using http or https.
I want to ensure that for some pages only https is acceptable.
Is there a variable in PHP that will give me the full URL including the protocol. I can then do a test and redirection.
 
TANSTAAFL!! sleipnir you put me on the right track.
My testing may be of use to future programmers looking for the same indicator:
I wrote a little php routine to list all the members of $_SERVER. Nothing useful showed up except the server port (which was 80) as I had invoked the program using http.
When I tested the same routine using https, the port changed to 443, so I have an indicator. THEN I noticed that there was a new element called HTTPS (it did not show up in the first test not having been set) with a value of "on".
This is a much more direct test and it works well.
 
Obviously, you already have what you need, but I believe $_SERVER['SERVER_PROTOCOL'], will also give you what you're looking for.

Itshim
 
Itshim,
Your suggestion rendered

SERVER_PROTOCOL => HTTP/1.

using https:// and http://

 
Sorry I didn't have a server to test it on, I was just paging through the manual and thought it would work.

Thanks,
Itshim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top