Showing posts with label protocol. Show all posts
Showing posts with label protocol. Show all posts

Tuesday, 13 May 2014

How to check url contains http or htttps in php

Hi with the following code you can get the protocol of the server  
 
 
 
if (isset($_SERVER['HTTPS']) &&
    ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
    isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
    $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
  $protocol = 'https://';
}
else {
  $protocol = 'http://';
}