0

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

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.