Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

IN my httpd.conf I am setting a variable

SetEnv MY_URL_WWW       ""

And in my .htaccess, i have a rewrite rule, where i want to redirect to my ENV url

RewriteRule ^redirect$ %{ENV:MY_URL_WWW} [L,NC,R=301,QSA]

This is not working, and i really want it to, what am i doing wrong?

share|improve this question

You must set it with RewriteRule. Try this:

RewriteRule .* - [E=MY_URL_WWW:]

PS: you can enable the mod_rewrite log with RewriteLog and RewriteLogLevel to see what happen.

share|improve this answer
so the environment variables in the apache config are not exactly the same environment variables that the mod_rewrite module uses? – Roy Rico Jul 28 '11 at 11:50
The environment variables set by SetEnv directive are set the last after early request processing (such as RewriteRule) are run. Have a look at: mod_env and SetEnv directive. – quanta Jul 28 '11 at 14:58
Ah, good to know. – Roy Rico Jul 28 '11 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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