Friday, 6 July 2012

How to check HTTPS



2
$_SERVER['HTTPS'] - this check HTTPS or HTTP
3
$_SERVER['SERVER_NAME'] - this return server name
4
$_SERVER['REQUEST_URI'] - this return client request
5

6
//assign the URL to variable
7
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
8
//display the URL
9
echo $url;

No comments: