I'm trying to set an Environment variable if I got a specific HTTP Header sent.
So I tried a few different way that I will detail
Header set MY_HTTP_HEADER "1"
# tests with with SetEnvIf
SetEnvIf %{HTTP:MY_HTTP_HEADER} ^1$ THE_ENV=ok
SetEnvIf MY_HTTP_HEADER ^1$ THE_ENV=ok
SetEnvIf %{MY_HTTP_HEADER} ^1$ THE_ENV=ok
# tests with RewriteRule
RewriteCond %{HTTP:MY_HTTP_HEADER} ^1$
RewriteRule .* index.php [L,E=THE_ENV:ok]
RewriteCond MY_HTTP_HEADER ^1$
RewriteRule .* index.php [L,E=THE_ENV:ok]
There is something that I certainly missed, because all the codes above doesn't work.
EDIT
The correct one is SetEnvIf MY_HTTP_HEADER ^1$ THE_ENV=ok and like @anubhava pointed it doesn't work if you set the header in the same .htaccess so I created another page calling the actual page with CURL with this header curl_setopt($curl,CURLOPT_HTTPHEADER,array('MY_HTTP_HEADER: 1'));
MY_HTTP_HEADERheader in the request?