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
Best Answer
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: