title: Nginx : add GET parameter if not present
body: <p>I'm using Nginx to (among other things) act as a proxy for <a href="http://www.subsonic.org/pages/index.jsp" rel="nofollow">Subsonic</a> on my local machine (i.e. Nginx has a <code>proxy_pass</code> setting to redirect all traffic directed to <code>subsonic.mydomain.com</code> towards <code>localhost:4040</code>).</p>
  
  <p>When accessing the main view without any GET parameters (<code>/home.view</code>), Subsonic shows the Random page, with random albums from my library. The Recently Added page is accessible by clicking a link to <code>/home.view?listType=newest</code>) but I would like it to be the default, without messing with Subsonic's code as this would break when updating Subsonic.</p>
  
  <p>Using a simple <code>rewrite</code> doesn't seem like a solution because rewrites take only URIs into account, without the GET parameters. Therefore rewriting <code>^/home.view$</code> as <code>/home.view?listType=newest</code> will always show the Recently Added page even when I request other pages.</p>
  
  <p>I would like to add the <code>listType</code> parameter only if it is not already present in the request, or add it in such a way that it gets overriden by the value in the request if it exists. Is there a way to do that in Nginx?</p>
  
  <p>Thanks a lot!</p>