# How to conditionally set enviroment variable

**URL:** <https://www.ruby-forum.com/t/how-to-conditionally-set-enviroment-variable/199476>\
**Category:** NGINX\
**Created:** [November 22, 2010, 3:35pm UTC](https://www.ruby-forum.com/t/how-to-conditionally-set-enviroment-variable/199476 "2010-11-22T15:35:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 22, 2010, 3:35pm UTC](https://www.ruby-forum.com/t/how-to-conditionally-set-enviroment-variable/199476/1 "2010-11-22T15:35:46Z")

</div>

Moin!

To make use of Magento’s multistore feature I need to tell it which  
store to load. This is done wih an environemnt variable.

Is there a way to make something like this work in “server” context:

if ($host ~\* .(at|ch|de)v?$) {  
env MAGE\_RUN\_CODE=storeview\_$1;  
}

ATM it seems I cannot use ‘env’ in “server” context, and in a hight  
context I cannot use ‘if’.
