title: nginx map module - using regex in included file
body: <p>I'm using nginx and its map module (<a href="http://wiki.nginx.org/HttpMapModule" rel="nofollow noreferrer">http://wiki.nginx.org/HttpMapModule</a>) to create rewrites depending on $args value.
  My config looks like the following:<br />
  nginx.conf</p>
  <pre><code>map $args $myvar {
      default 0;
      include /path/to/file.conf;
  } 
  </code></pre>
  <p>file.conf has something like:</p>
  <pre><code>foo=1 /url1;
  foo=2 /url2;
  ....
  foo=n /urln;
  </code></pre>
  <p>afterwards I'm using $myvar for redirects like this</p>
  <pre><code>location = /somepage.html {
      if ($myvar !~ 0) {
          rewrite ^ $myvar? permanent;
      }
      rewrite ^ /mydefaultpage/? permanent;
  } 
  </code></pre>
  <p>The question is: can I use regex inside my file.conf, which I include inside my <code>map</code> directive? So I could write something like</p>
  <pre><code>~^foo=1(&amp;&lt;suffix&gt;.*)$ /url1?$suffix;
  </code></pre>
  <p>and thus preserve all other args when redirecting to /url1.</p>
  <p>Thanks in advance for your help!</p>