Use SetEnv Variable in htaccess Rewrite Rule

.htaccessapache-2.2mod-rewrite

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?

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

Best Answer

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

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