Hi all,<br><br>I have a problem with nginx&#39;s urlencoding when it does a rewrite and passes it on to a proxy backend. Below is the config:<br><br>location ~ ^/search/([^/]+)/?([^-/&amp;]+)?.*$ {<br>  set $query $1;<br>  set $filter $2;<br>
<br>  rewrite ^ /search?q=$query&amp;cat=$filter&amp;$args? last;<br>}<br><br>location ~ ^/(search) {<br><br>                proxy_read_timeout 180;<br>                proxy_set_header X-Real-IP $remote_addr;<br>                proxy_pass <a href="http://load_balance">http://load_balance</a>;<br>
}<br><br><br>I match requests like :<br><br>/search/queryABC/fitlerDEF<br>/search/queryABC<br>/search/queryABC/ <br><br>and rewrite it to<br><br>/search?q=queryABC&amp;cat=filterDEF<br>/search?q=queryABC<br>/search?q=queryABC<br>
<br>which all works properly.<br><br>Now the problem is if the query has special characters like &amp; , &quot;, &#39; etc... they are not urlencoded before rewriting:<br><br>Eg:<br><br>/search/jhonson&amp;jhonson  becomes  /search?q=jhonson&amp;jhonson    but what I expect is: /search?q=jhonson&amp;26jhonson<br>
<br>/search/&quot;tourism in paris&quot; becomes /search?q=\&quot;tourism%20in%20paris\&quot;  but what I expect is /search?q=%22tourism%20in%20paris%22  [This is weird spaces are urlencoded properly]<br><br>Even if i try to urlencode it from the frontend(Javascript) like:<br>
<br>/search/jhonson&amp;26jhonson still becomes /search?q=jhonson&amp;jhonson  which again looks weird to me ! <br><br>Am i missing anything? Is there anything that i can do to get what i expect ?<br><br>Thanks<br>Harish<br>
<br>