# X-Accel-Redirect doesn't URL-decode paths

**URL:** <https://www.ruby-forum.com/t/x-accel-redirect-doesnt-url-decode-paths/194593>\
**Category:** NGINX\
**Created:** [September 7, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-doesnt-url-decode-paths/194593 "2010-09-07T17:21:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustavo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@gustavo](https://www.ruby-forum.com/u/gustavo)\
**Post date:** [September 7, 2010, 5:21pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-doesnt-url-decode-paths/194593/1 "2010-09-07T17:21:09Z")

</div>

Hello,

I’m using the X-Accel-Redirect feature in Nginx, but it fails to send  
some files (returning a 404) because it does not URL-decode the  
requested path. It does work when the file name need not be  
URL-decoded.

So, for example, I have a file called “MudanÃ§a\_ClimÃ¡tica.pdf” in  
/srv/static (whose URL alias on Nginx is “/internal/static”), my  
application would set the X-Accel-Redirect header to:  
X-Accel-Redirect: /internal/static/Mudan%C3%A7a\_Clim%C3%A1tica.pdf

But then, Nginx will try to look up that file in the filesystem as:  
/srv/static/Mudan%C3%A7a\_Clim%C3%A1tica.pdf

However, if I requested “Climate\_Change.pdf”, it works.

This seems like a bug, isn’t it? Or is it a bad configuration?

Thanks in advance.

Posted at Nginx Forum:

> **[X-Accel-Redirect doesn't URL-decode paths](https://forum.nginx.org/read.php?2,128004,128004#msg-128004)**
>
> Hello, I'm using the X-Accel-Redirect feature in Nginx, but it fails to send some files (returning a 404) because it does not URL-decode the requested path. It does work when the file name need not be URL-decoded. So, for example, I have a file...

---

<div class="post-metadata">

**Author:** ![gustavo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@gustavo](https://www.ruby-forum.com/u/gustavo)\
**Post date:** [September 7, 2010, 5:45pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-doesnt-url-decode-paths/194593/2 "2010-09-07T17:45:45Z")

</div>

Hello!

On Tue, Sep 07, 2010 at 11:20:08AM -0400, gustavo wrote:

> ```
> X-Accel-Redirect: /internal/static/Mudan%C3%A7a_Clim%C3%A1tica.pdf
> 
> ```
> 
> But then, Nginx will try to look up that file in the filesystem as:  
> /srv/static/Mudan%C3%A7a\_Clim%C3%A1tica.pdf
> 
> However, if I requested “Climate\_Change.pdf”, it works.
> 
> This seems like a bug, isn’t it? Or is it a bad configuration?

X-Accel-Redirect expected to contain non-encoded URI. This isn’t  
really right, but it’s how it currently works.

Maxim D.

---

<div class="post-metadata">

**Author:** ![gustavo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a9adbd/32.png) [@gustavo](https://www.ruby-forum.com/u/gustavo)\
**Post date:** [September 7, 2010, 5:56pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-doesnt-url-decode-paths/194593/3 "2010-09-07T17:56:18Z")

</div>

Hi, Maxim.

Thank you very much for your response.

Maxim D. Wrote:

> X-Accel-Redirect expected to contain non-encoded  
> URI. This isn’t  
> really right, but it’s how it currently works.

It’s not only against HTTP, it’s also a big limitation because gateways  
like Python’s mod\_wsgi (or any gateway for Python/WSGI) would refuse to  
send decoded values in HTTP headers.

Do you know if is there a workaround for this?

Thanks in advance.

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,128004,128020#msg-128020](http://forum.nginx.org/read.php?2,128004,128020#msg-128020)
