we have a multisite set-up and need to map domains and domains/subfolders to a variable. This way the programming knows which version to load.
We have stores that h
When default
is not specified in a map block, the default resulting value will be an empty string. So, in your case, whatever value $storecode
is set with in the first map block, it is replaced with an empty string in the second one.
Since map variables are evaluated when they are used, you cannot set $storecode
as the default value in the second map block, because that will cause an infinite loop.
So the solution is to introduce a temporary variable in the first map block and then use it as the default value in the second block:
map $host $default_storecode {
default dom_nl;
domain.com dom_nl;
domain.de dom_de;
store.com str_de;
}
map $host$uri $storecode {
default $default_storecode;
~^store.com/en.* str_en;
~^store.com/fr.* str_fr;
}
Alternatively, you can merge these two map blocks into one:
map $host$uri $storecode {
default dom_nl;
~^domain.com.* dom_nl;
~^domain.de.* dom_de;
~^store.com/en.* str_en;
~^store.com/fr.* str_fr;
~^store.com.* str_de;
}