Welcome! Log In Create A New Profile

Advanced

URL encoding issue

Harish Sundararaj
April 15, 2010 06:46AM
Hi all,

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:

location ~ ^/search/([^/]+)/?([^-/&]+)?.*$ {
set $query $1;
set $filter $2;

rewrite ^ /search?q=$query&cat=$filter&$args? last;
}

location ~ ^/(search) {

proxy_read_timeout 180;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://load_balance;
}


I match requests like :

/search/queryABC/fitlerDEF
/search/queryABC
/search/queryABC/

and rewrite it to

/search?q=queryABC&cat=filterDEF
/search?q=queryABC
/search?q=queryABC

which all works properly.

Now the problem is if the query has special characters like & , ", ' etc...
they are not urlencoded before rewriting:

Eg:

/search/jhonson&jhonson becomes /search?q=jhonson&jhonson but what I
expect is: /search?q=jhonson&26jhonson

/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]

Even if i try to urlencode it from the frontend(Javascript) like:

/search/jhonson&26jhonson still becomes /search?q=jhonson&jhonson which
again looks weird to me !

Am i missing anything? Is there anything that i can do to get what i expect
?

Thanks
Harish
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

URL encoding issue

Harish Sundararaj April 15, 2010 06:46AM

Re: URL encoding issue

Maxim Dounin April 15, 2010 08:50PM

Re: URL encoding issue

acaron February 16, 2011 08:41AM

Re: URL encoding issue

Igor Sysoev February 16, 2011 09:02AM

Re: URL encoding issue

Maxim Dounin February 16, 2011 09:22AM

REDIS2 Addon, Query LRANGE Support?

Alexander Kunz February 16, 2011 01:18PM

Re: REDIS2 Addon, Query LRANGE Support?

Alexander Kunz February 16, 2011 02:44PM

Re: URL encoding issue

acaron February 20, 2011 12:18AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 329
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready