Skip to content

Instantly share code, notes, and snippets.

@marcocesarato
Created July 30, 2018 12:54
Show Gist options
  • Save marcocesarato/eec0b5c2ebead9cc006688b842e0a81c to your computer and use it in GitHub Desktop.
Save marcocesarato/eec0b5c2ebead9cc006688b842e0a81c to your computer and use it in GitHub Desktop.
Check if site run over https
<?php
/**
* Check if site run over https
*
* @author Marco Cesarato <cesarato.developer@gmail.com>
* @return boolean
*/
if (!function_exists('is_https')){
function is_https(){
if (isset($_SERVER['HTTP_HOST'])){
if(((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443)
|| !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on'){
return true;
}
return false;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment