Hi all,<br><br>I have a problem with nginx's urlencoding when it does a rewrite and passes it on to a proxy backend. Below is the config:<br><br>location ~ ^/search/([^/]+)/?([^-/&]+)?.*$ {<br> set $query $1;<br> set $filter $2;<br>
<br> rewrite ^ /search?q=$query&cat=$filter&$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&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 & , ", ' etc... they are not urlencoded before rewriting:<br><br>Eg:<br><br>/search/jhonson&jhonson becomes /search?q=jhonson&jhonson but what I expect is: /search?q=jhonson&26jhonson<br>
<br>/search/"tourism in paris" becomes /search?q=\"tourism%20in%20paris\" 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&26jhonson still becomes /search?q=jhonson&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>