Skip to content

Instantly share code, notes, and snippets.

@neo22s
Created September 2, 2016 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neo22s/27e83161d928e9252c2496c7748adb79 to your computer and use it in GitHub Desktop.
Save neo22s/27e83161d928e9252c2496c7748adb79 to your computer and use it in GitHub Desktop.
is_HTTPS_protocol working until today.
<?php
/**
* checks if is https by protocol used in nginx
* @return boolean
*/
public static function is_HTTPS_protocol()
{
//we are sure is a https request , we use first the Nginx forwarded PROTO OR apache
if( (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) AND $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
OR (isset($_SERVER['REQUEST_SCHEME']) AND $_SERVER['REQUEST_SCHEME'] == 'https')
)
{
//so we can use it later
$_SERVER['HTTPS']='on';
return TRUE;
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment