Nginx Configuration – Map Directive for Multiple Variables in Magento

configurationmagentonginx

I currently use nginx with Magento and I use the map directive to supply the store code like this:

map $http_host $magecode {
        www.store.com retail_store;
        wholesale.store.com wholesale_store;
        beta.store.com retail_beta_view;
}

The drawback to this is if I make the beta site its own store, I can't use the same catalog. Instead, I want to make the beta site a website instead of store.

Is it possible to map two variables at a time? I am imagining it would look like this:

map $http_host $magecode $magetype {
        www.store.com retail_store website;
        wholesale.store.com wholesale_store website;
        beta.store.com retail_beta_view store;
}

If not can I map the same variable twice?

map $http_host $magecode { ... }
map $http_host $magetype { ... }

Best Answer

Yes, you can use more than one map and that seems to be the cleanest way to solve this.

map $http_host $magecode {
        www.store.com retail_store;
        wholesale.store.com wholesale_store;
        beta.store.com retail_beta_view;
}

map $http_host $magetype {
        www.store.com website;
        wholesale.store.com website;
        beta.store.com store;
}
Related Topic