February 2018
Beginner to intermediate
348 pages
9h 40m
English
Just like the Browser module, the Map module allows you to create maps of values, depending on a variable:
map $uri $variable {
/page.html 0;
/contact.html 1;
/index.html 2;
default 0;
}
rewrite ^ /index.php?page=$variable;
The map directive can only be inserted within the http block. Following this example, $variable may have three different values. If $uri was set to /page.html, $variable, the value is now defined as 0; if $uri was set to /contact.html, $variable is now 1; if $uri was set to /index.html, $variable, the value now equals 2. For all other cases (default), $variable is set to 0. The last instruction rewrites the URL accordingly. Apart from default, the map directive accepts another special keyword: hostnames. It allows ...
Read now
Unlock full access