Apmersand in rewrite rule is escaped if url encoded value exists

I want to transfer
/script/action/var1___val1/var2___val2/…/varN___valN/ to
/script/action?var1=val1&var2=val2&…&varN=valN. My rewrite rules are:

rewrite ^/script/(.)/(\w+)___([^/]+)/(.)$ /script/$1/$2=$3&$4? last;
rewrite ^/script/(\w+)/(.+) /script/$1?$2 break;

If value of val1/val2/…/valN is alphabets or digits, the rules works
fine. Once url encoded value appears, the apmersands connecting
variable-value pairs are escaped to ‘%26’ which makes it sucks.

Can somebody help me?

Thanks, Kenny.

Posted at Nginx Forum: