在我们的httpd.conf虚拟主机块中
SetEnv MAGE_RUN_CODE "v2_us_es"
是否有可能在.htaccess文件中使用该variables
就像是
RewriteRule ^sitemap\.xml$ /media/sitemaps/%{MAGE_RUN_CODE}/sitemap.xml [L]
这可能吗?
谢谢!
杰夫
编辑:我查看了以下链接,但他们没有做我想做的事情
在 https://stackoverflow.com/questions/2008123/how-to-use-getenv-in-php-and-setenv-in-a -htaccess-a-compiled-php-cgi-on https://stackoverflow.com/questions/3638637/how-to-use-the-setenv-variable-in-apache
在mod_rewrite中使用环境variables的语法是%{ENV:VARNAME} :
RewriteRule ^sitemap\.xml$ media/sitemaps/%{ENV:MAGE_RUN_CODE}/sitemap.xml [L]
SetEnvvariables只是在RewriteRule中返回空string。 我认为这是因为它们在执行RewriteRule时没有被设置。 但SetEnvIf将工作,所以你可以尝试:
SetEnvIf Request_URI ^.*$ MAGE_RUN_CODE=v2_us_es
然后使用它:
RewriteRule ^sitemap\.xml$ /media/sitemaps/%{ENV:MAGE_RUN_CODE}/sitemap.xml [L]
SetEnvIf的Request_URI ^.*$只是检查请求的页面是什么或者什么都没有,所以总是设置variables。
它可能会更好地configuration为Apacheconfiguration文件中的“RewriteMap”。