# Regex

**URL:** <https://www.ruby-forum.com/t/regex/183707>\
**Category:** NGINX\
**Created:** [February 18, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/regex/183707 "2010-02-18T22:04:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![budala10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@budala10](https://www.ruby-forum.com/u/budala10)\
**Post date:** [February 18, 2010, 10:04pm UTC](https://www.ruby-forum.com/t/regex/183707/1 "2010-02-18T22:04:28Z")

</div>

Hi, if i have a url ending with a / how can i rewrite the request before  
go to the proxy so the ending slash is dropped?

i want [www.host.com/uri/](http://www.host.com/uri/) to be [www.host.com/uri](http://www.host.com/uri)

Posted at Nginx Forum:

> **[regex](https://forum.nginx.org/read.php?2,55377,55377#msg-55377)**
>
> Hi, if i have a url ending with a / how can i rewrite the request before go to the proxy so the ending slash is dropped? i want www.host.com/uri/ to be www.host.com/uri

---

<div class="post-metadata">

**Author:** ![budala10](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/58f4c7/32.png) [@budala10](https://www.ruby-forum.com/u/budala10)\
**Post date:** [February 18, 2010, 10:41pm UTC](https://www.ruby-forum.com/t/regex/183707/2 "2010-02-18T22:41:56Z")

</div>

budala10 wrote:

> Hi, if i have a url ending with a / how can i rewrite the request before go to the proxy so the ending slash is dropped?

rewrite ^(.\*)/$ $1;

This is because in nginx you cannot substitute part of the url. The  
replacement string is always considered as a whole new url. So this will  
not work:

rewrite /$ “”; # DOESN’T WORK

Tobia
