How can $_SERVER['HTTPS'] be empty when accessing over HTTPS?

apache, https, php

Solution

to properly use SetEnv in your .htaccess you need the mod_env module, like:

<IfModule mod_env.c>
   SetEnv HTTPS on
</IfModule>

otherwise, the $_SERVER["HTTPS"] will be empty..

Problem

I am having a problem with `$_SERVER['HTTPS']` being empty when I am actually accessing a page over https. According to the docs for `$_SERVER`, this should be non-empty when accessing a page over HTTPS. Accoding the docs for mod_ssl This module provides a lot of SSL information as additional environment variables to the SSI and CGI namespace. Does this mean that I need to explicitly ``` SetEnv HTTPS on ``` in Apache if PHP is running as mod_php to get `$_SERVER['HTTPS']` set? I am trying to figure out if something is wrong in my system or if I am seeing normal behavior.

Original source