title: nginx rewrite url path to a param
body: <p>Now I have an URL of this type:</p>
  
  <p><code>test.com/p/felix?order=1</code></p>
  
  <p>And I want to redirect it to this one:</p>
  
  <p><code>test.com/user/view/info?uname=felix&amp;order=1</code></p>
  
  <p>and maybe there is no order param</p>
  
  <p><code>(test.com/p/felix to test.com/user/view/info?uname=felix)</code></p>
  
  <p>Now my nginx config is :</p>
  
  <pre><code>if ($request_uri ~ "^\/p\/(.*)\?(.*)$"){
          rewrite "^/p/(.*)?(.*)$" "/user/view/info?uname=$1&amp;$2" break;
  }
  if ($request_uri ~ "^\/p\/(.*)$"){
              rewrite "^/p/(.*)$" "/user/view/info?uname=$1" break;
  }
  </code></pre>
  
  <p>It works now. But I want to merge this two config into one config?</p>
  
  <p>Could you tell me how to do it thanks :)</p>