# Url escape variable

**URL:** <https://www.ruby-forum.com/t/url-escape-variable/227949>\
**Category:** NGINX\
**Created:** [April 4, 2013, 10:44am UTC](https://www.ruby-forum.com/t/url-escape-variable/227949 "2013-04-04T10:44:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/71e660/32.png) [@cris](https://www.ruby-forum.com/u/cris)\
**Post date:** [April 4, 2013, 10:44am UTC](https://www.ruby-forum.com/t/url-escape-variable/227949/1 "2013-04-04T10:44:16Z")

</div>

Hello

I have this issue trying to use post\_action

My config is like this:  
location / {  
post\_action /afterdownload;  
…  
…  
…  
location /afterdownload {  
proxy\_pass  
[http://78.140.165.80/download\_counter.php?FileName=$request&status=$request\_completion](http://78.140.165.80/download_counter.php?FileName=$request&status=$request_completion)  
;  
internal;  
}

How to escape the content of $request so it’s a valid URL?

Right now the value there is like (from the log)

78.140.165.80 - - [04/Apr/2013:10:36:53 +0200] "GET  
/download\_counter.php?FileName=GET  
/storage/files/0/1/17/176/myvideo.avi?md=IfHSTECs

I get a 400 (Bad request) for this call and I guess it’s because the  
space  
after GET inside this variable.

How can I either escape or run a replace on it to remove GET\_ from the  
beginning of it?
