title: Nginx $is_args and $args cleared after rewrite
body: <p>I am trying to write in the access log some info that depends on whether the original request had query params or not, and for this purpose I use $is_args within the $http block.</p>
  <p>For instance, if the received request was <a href="http://www.website.com/something&amp;a=1&amp;b=2" rel="nofollow noreferrer">http://www.website.com/something&amp;a=1&amp;b=2</a>, the access log line should be</p>
  <pre><code>.... [GET params:true] ...
  </code></pre>
  <p>But if the requet was <a href="http://www.website.com/something" rel="nofollow noreferrer">http://www.website.com/something</a>, then the access log line should be</p>
  <pre><code>.... [GET params:false] ...
  </code></pre>
  <p>I also have a <code>location</code> context which does a rewrite:</p>
  <pre><code>    if ( $redirect_to_somewhere = &quot;true&quot;) {
          return 302 $redirect_loc;
      }
  </code></pre>
  <p>My problem is that after the rewrite is executed, <code>$args</code> and <code>$is_args</code> variables get empty and return nothing.
  If the rewrite doesn't happen, $args and $is_args have the correct values from the original request.</p>
  <p>What can I do to have the <code>$is_args</code> value of the original request despite the rewrite?
  My only solution that currently works is to set a variable just before the return:</p>
  <pre><code>set $original_is_args $is_args;
  </code></pre>
  <p>and then use it outside the server scope, but I've seen warnings not to use variables that are set this way outside server{}.
  I also prefer not to use regex matching for performance reasons.</p>
  <p>Is there a possible solution?</p>
  <p>Edit: After the redirection, there's a navigation to an error page(which is normal in my case) so the args from the original request aren't reserved. The question is still valid - how to still have original args(or is_args) without having to parse $request_uri.</p>