Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define was page requested over https or http? [duplicate]

Tags:

http

php

https

Possible Duplicate:
PHP: HTTP or HTTPS? How can one tell?

Is there a way to define this?

$_SERVER superglogal doesn't provide such info. Even only it's ['SERVER_PROTOCOL'] ...

like image 430
s.webbandit Avatar asked Jan 28 '26 01:01

s.webbandit


1 Answers

If your request is sent by HTTPS you will have an extra server variable named 'HTTPS'

if( isset($_SERVER['HTTPS'] )  && $_SERVER['HTTPS'] != 'off' ) 
{
   echo 'HTTPS';
}
else
{
  echo 'HTTP';
}
like image 98
Aelios Avatar answered Jan 30 '26 14:01

Aelios



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!