# URL encoding for nginx rewrites

**URL:** <https://www.ruby-forum.com/t/url-encoding-for-nginx-rewrites/231875>\
**Category:** NGINX\
**Created:** [September 3, 2014, 8:09pm UTC](https://www.ruby-forum.com/t/url-encoding-for-nginx-rewrites/231875 "2014-09-03T20:09:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [September 3, 2014, 8:09pm UTC](https://www.ruby-forum.com/t/url-encoding-for-nginx-rewrites/231875/1 "2014-09-03T20:09:31Z")

</div>

Hello everyone.  
I am using a rewrite similar to below

```
location /home {
    rewrite ^/(.*) https://mysite.com/homepage/?next=/redirectionurl

```

redirect;  
}

The issue is that nginx is not encoding the URL before it redirects.

So this is failing at the server that is receiving this request.

Can someone help me in encoding the rewritten URL.

Thanks a lot in advance

Posted at Nginx Forum:

> **[URL encoding for nginx rewrites](https://forum.nginx.org/read.php?2,253045,253045#msg-253045)**
>
> Hello everyone. I am using a rewrite similar to below location /home { rewrite ^/(.\*) https://mysite.com/homepage/?next=/redirectionurl redirect; } The issue is that nginx is not encoding the URL before it redirects. S
