LoginSignup
1
1

More than 5 years have passed since last update.

PHPでhttps環境か調べる

Last updated at Posted at 2018-05-17
//SSL
if (
    isset($_SERVER['HTTPS']         )                                                                                   ||
    isset($_SERVER['REDIRECT_HTTPS'])                                                                                   ||
    ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']          ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO']         )   ||  //AWS
    ( isset($_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'])       //AWS(CloudFront)
) {
    return true;
//非SSL
} else {
    return false;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1