# Apmersand in rewrite rule is escaped if url encoded value exists

**URL:** <https://www.ruby-forum.com/t/apmersand-in-rewrite-rule-is-escaped-if-url-encoded-value-exists/220000>\
**Category:** NGINX\
**Created:** [May 24, 2012, 1:30pm UTC](https://www.ruby-forum.com/t/apmersand-in-rewrite-rule-is-escaped-if-url-encoded-value-exists/220000 "2012-05-24T13:30:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 24, 2012, 1:30pm UTC](https://www.ruby-forum.com/t/apmersand-in-rewrite-rule-is-escaped-if-url-encoded-value-exists/220000/1 "2012-05-24T13:30:23Z")

</div>

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:

> **[apmersand in rewrite rule is escaped if url encoded value exists](https://forum.nginx.org/read.php?2,226798,226798#msg-226798)**
>
> 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...
