Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess SetEnv REDIRECT_ prefix

I'm setting an environment variable in an htaccess file and it's being prepended with "REDIRECT_". As far as I've read, this is caused by URL rewriting.. the thing is, I'm not doing any rewriting (that I'm aware of).

My webspace contains two files:

.htaccess

SetEnv Foo "bar"

index.php

<?php
print_r($_ENV);

Now, I'm guessing this may have something to do with the fact that this is on a shared hosting package with 1&1.. is there anything else I should be checking or has anyone experienced this before? Or am I just missing something??

Cheers

like image 401
user1187347 Avatar asked Sep 18 '25 16:09

user1187347


1 Answers

The issue is triggered by using PHP as a CGI Wrapper. If PHP is running as mod_php apache module it's not prefixing your variables.

Reason for that is internal redirect handling thus apache recreates the variables with the REDIRECT_ prefix :-/

Solution (updated)

Use PHP-FPM or mod_php

If you wanna use CGI Wrapping for PHP put this into your .htaccess:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
like image 115
Rico Neitzel Avatar answered Sep 20 '25 12:09

Rico Neitzel