Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

IN my httpd.conf I am setting a variable

SetEnv MY_URL_WWW       "http://myURLtowhatever.com"

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

1 Answer 1

You must set it with RewriteRule. Try this:

RewriteRule .* - [E=MY_URL_WWW:http://myURLtowhatever.com]

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
1  
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

 
discard

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.