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?

Roy Rico
  • 612
  • 2
  • 9
  • 20

1 Answers1

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.

quanta
  • 51,413
  • 19
  • 159
  • 217
  • 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
  • 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](http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv) and [SetEnv](http://httpd.apache.org/docs/2.0/env.html) directive. – quanta Jul 28 '11 at 14:58
  • Ah, good to know. – Roy Rico Jul 28 '11 at 15:43