# URL decoding a variable and/or using rewite effectively

**URL:** <https://www.ruby-forum.com/t/url-decoding-a-variable-and-or-using-rewite-effectively/214126>\
**Category:** NGINX\
**Created:** [November 22, 2011, 6:11pm UTC](https://www.ruby-forum.com/t/url-decoding-a-variable-and-or-using-rewite-effectively/214126 "2011-11-22T18:11:19Z")\
**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:** [November 22, 2011, 6:11pm UTC](https://www.ruby-forum.com/t/url-decoding-a-variable-and-or-using-rewite-effectively/214126/1 "2011-11-22T18:11:19Z")

</div>

Thank you in advance to anyone who can point me in the right direction.

We currently use nginx as an asset server. Requests are made to the  
asset server in the form of:  
[http://downloads.ourdomain.com?unique\_key=MD5hashOFstuff&name=the\_nice\_file\_name](http://downloads.ourdomain.com?unique_key=MD5hashOFstuff&name=the_nice_file_name)(that  
might have quotes or spaces)

The unique key is the actual name of the file, however we use $arg\_NAME  
in the headers to control the downloaded name. eg:  
add\_header Content-Disposition “attachment;filename=$arg\_NAME.xslx”;  
(yes they are excel files).

Our current issue is that space, parenthesis and other characters become  
URL encoded in the variable. As such, the file-name (as it appears in  
download) is not quite what we would like. My research has led me to  
find that there is currently no access to a ‘url-decode’ style function.  
I was curious, though, if there might be another method someone could  
think to employ. Perhaps I have access to regular expression replace  
style functionality that I am unaware of. Something that simple, would  
more then likely solve all of the issues for this particular case.

Thank you for taking the time to read this,

-Mike  
(kung\_fu\_mike)

Posted at Nginx Forum:

> **[URL decoding a variable and/or using rewite effectively](https://forum.nginx.org/read.php?2,218754,218754#msg-218754)**
>
> Thank you in advance to anyone who can point me in the right direction. We currently use nginx as an asset server. Requests are made to the asset server in the form of:...
