title: Rewrite query string to path params
body: <p>I have the following configuration of nginx that hosts my image service:</p>
  
  <pre><code>    upstream thumbor {
          server localhost:8888;
      }
  
      server {
          listen       80;
          server_name  my.imageserver.com;
          client_max_body_size 10M;
          rewrite_log on;
          location ~ /images { 
              if ($arg_width="10"){
                  rewrite ^/images(/.*)$ /unsafe/$1 last;
              }
              rewrite ^/images(/.*)$ /unsafe/$1 last;
          }
          location ~ /unsafe {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header HOST $http_host;
              proxy_set_header X-NginX-Proxy true;
  
              proxy_pass http://thumbor;
              proxy_redirect off;
          }
  
          location = /favicon.ico {
              return 204;
              access_log     off;
              log_not_found  off;
          }
      }
  </code></pre>
  
  <p>I am trying to rewrite the following urls:</p>
  
  <p><strong>from</strong></p>
  
  <p><a href="http://my.imageserver.com/images/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg" rel="nofollow">http://my.imageserver.com/images/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg</a></p>
  
  <p><strong>to</strong></p>
  
  <p><a href="http://my.imageserver.com/unsafe/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg" rel="nofollow">http://my.imageserver.com/unsafe/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg</a></p>
  
  <p>which is quite easy, the problem begins when I want to allow query string that should go to the path of the url like so:</p>
  
  <p><strong>from</strong></p>
  
  <p><a href="http://my.imageserver.com/images/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg?width=150&amp;height=200&amp;mode=smart" rel="nofollow">http://my.imageserver.com/images/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg?width=150&amp;height=200&amp;mode=smart</a></p>
  
  <p><strong>to</strong></p>
  
  <p><a href="http://my.imageserver.com/unsafe/150x200/smart/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg" rel="nofollow">http://my.imageserver.com/unsafe/150x200/smart/Jenesis/EmbeddedImage/image/jpeg/jpeg/9f5d124d-068d-43a4-92c0-1c044584c54a.jpeg</a></p>
  
  <p>Also it will be better if the order of the query strings won't matter.</p>
  
  <p>I tried using:
  $arg_width but it didn't seem to work.</p>
  
  <p>Using nginx 1.6.1 on ubuntu.</p>
  
  <p>Help would be much much appreciated.</p>