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

In our httpd.conf virtual host block we have

SetEnv MAGE_RUN_CODE "v2_us_es"

Is it possible to use that variable in a .htaccess file

Something like

RewriteRule ^sitemap\.xml$ /media/sitemaps/%{MAGE_RUN_CODE}/sitemap.xml [L]

Is this possible?

Thank you!


Edit: I viewed the following links, but none of them do what I am trying to do

http://stackoverflow.com/questions/10727720/conditional-setenv-in-htaccess http://stackoverflow.com/questions/2008123/how-to-use-getenv-in-php-and-setenv-in-a-htaccess-with-a-compiled-php-cgi-on http://stackoverflow.com/questions/3638637/how-to-use-the-setenv-variable-in-apache

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The syntax to use environment variables in mod_rewrite is %{ENV:VARNAME}:

RewriteRule ^sitemap\.xml$ media/sitemaps/%{ENV:MAGE_RUN_CODE}/sitemap.xml [L]
share|improve this answer

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.