0

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?

1 Answer 1

2

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.

3
  • 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, 2011 at 11:50
  • 2
    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, 2011 at 14:58
  • Ah, good to know.
    – Roy Rico
    Jul 28, 2011 at 15:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .