<p>I'm looking to convert the following <code>mod_rewrite</code> rule to the <a href="http://wiki.codemongers.com/NginxHttpRewriteModule" rel="noreferrer">Nginx equivalent</a>:</p>

<pre><code>RewriteRule ^foo/(.*)$ /bar/index.php?title=$1 [PT,L,QSA]
RewriteRule ^foo/*$ /bar/index.php [L,QSA]
</code></pre>

<p>So far I have:</p>

<pre><code>rewrite ^foo/(.*)$ /bar/index.php?title=$1&amp;$query_string last;
rewrite ^foo/?$ /bar/index.php?$query_string break;
</code></pre>

<p>The problem is (I think!) that the query string doesn't get appended. I haven't found a way to port the <code>QSA</code> argument to Nginx.</p>

These rewrite rules made the scripts work:
```
```
rewrite ^/foo/([^?]*)(?:\?(.*))? /bar/index.php?title=$1&$2;
rewrite ^/foo /bar/index.php;
```
```