title: In Nginx, how to match and entire URL and Query String and redirect to a URL and Query String
body: <p>I have been searching for a while now, trying work arounds and haven't come up with anything useful.</p>
  
  <p>I have a (large) list of URL's from an site migration and need to match the entire URL + Query String and redirect to another URL. </p>
  
  <p>As far as I can see the following only matches <code>/mens</code>, but not the rest of the query string. </p>
  
  <pre><code>rewrite "^/mens?brand%5B%5D=27&amp;section%5B%5D=5&amp;price-min=0&amp;price-max=2000&amp;sort=newest"  "/t/gender/men" permanent;
  </code></pre>
  
  <p>The reason it's important is that I have a bunch of similar URL's with slightly different Query Strings, which need to be redirected, similar to below, but actually work.... :-/ </p>
  
  <pre><code>rewrite "^/mens/shop?q=road+map+polo"       "/t/category/golf-knits"    permanent;
  rewrite "^/mens/shop?q=six+pocket+pant"     "/t/category/golf-pants"    permanent;
  
  #etc... ad noiseam 
  </code></pre>
  
  <p>Thanks in advance, 
  Paul.</p>