1

I just wondered if it's possible to set an environment variable depending on the basic authentication user. I tried the following versions, but none of them work (obviously none of them is documented either):

SetEnvIf HTTP_USER "marco" MYENV=foobar SetEnvIf USER "marco" MYENV=foobar SetEnvIf REMOTE_USER "marco" MYENV=foobar 

Cheers, Marco

1 Answer 1

5

SetEnvIf is used to set environment variables based on attributes or header of the request. But the username is not an attribute of the request; it's an environment variable on its own that's being set by Apache once the request has already been processed. That's why it doesn't work the way you want it to.

There's a workaround you can do by taking the REMOTE_USER environment variable and putting it in a header:

RequestHeader set X-Remote-User expr=%{REMOTE_USER} SetEnvIf X-Remote-User "marco" MYENV=foobar 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.