# Nginx redirect/rewrite Rule

**URL:** <https://www.ruby-forum.com/t/nginx-redirect-rewrite-rule/243719>\
**Category:** NGINX\
**Created:** [December 26, 2015, 12:43pm UTC](https://www.ruby-forum.com/t/nginx-redirect-rewrite-rule/243719 "2015-12-26T12:43:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [December 26, 2015, 12:43pm UTC](https://www.ruby-forum.com/t/nginx-redirect-rewrite-rule/243719/1 "2015-12-26T12:43:24Z")

</div>

Nginx redirect/rewrite Rule

Old Url  
[http://www.mydomain.com.br/forum/elsword-downloads-de-cheats-utilitarios/2369461-26-04-revolution-trainer-elsword.html](http://www.mydomain.com.br/forum/elsword-downloads-de-cheats-utilitarios/2369461-26-04-revolution-trainer-elsword.html)

1. /forum/ - It is the folder that installed vbulletin
2. /elsword-downloads-de-cheats-utilitarios/ - is the forum name that  
the  
topic / in xenforo will not appear
3. 2369461 - is the ID that will have to appear in the url xenforo
4. -26-04-revolution-trainer-elsword.html - is the topic name that  
accessing, no matter what the xenforo because with the right ID it  
corrects  
the topic name in the URL.

New Url  
[http://www.mydomain.com.br/threads/26-04-revolution-trainer-elsword.2369461/](http://www.mydomain.com.br/threads/26-04-revolution-trainer-elsword.2369461/)

1. /threads/ - the xenforo automatically add the address when accessing  
this  
one topic.
2. 26-04-revolution-trainer-elsword - Topic name, even if the xenforo  
system  
corrects’m wrong
3. 2369461 - Most importantly, the topic ID

Another examples

Old Url  
[http://www.mydomain.com.br/forum/resolvidos/2343690-reposicao-dos-meus-posts.html](http://www.mydomain.com.br/forum/resolvidos/2343690-reposicao-dos-meus-posts.html)

New Url  
[http://www.mydomain.com.br/threads/reposição-dos-meus-posts.2343690/](http://www.mydomain.com.br/threads/reposi%C3%A7%C3%A3o-dos-meus-posts.2343690/)

Old Url  
[http://www.mydomain.com.br/forum/league-of-legends-downloads-de-cheats-utilitarios/2516190-drophack-1-3-funcional-apenas-por-30-dias-aproveite-o-mais-rapido-possivel-veja-ma.html](http://www.mydomain.com.br/forum/league-of-legends-downloads-de-cheats-utilitarios/2516190-drophack-1-3-funcional-apenas-por-30-dias-aproveite-o-mais-rapido-possivel-veja-ma.html)

New Url  
[http://www.mydomain.com.br/threads/drophack-1-3-funcional-apenas-por-30-dias-aproveite-o-mais-rapido-possivel-veja-ma.2516190/](http://www.mydomain.com.br/threads/drophack-1-3-funcional-apenas-por-30-dias-aproveite-o-mais-rapido-possivel-veja-ma.2516190/)

Posted at Nginx Forum:

> **[Nginx redirect/rewrite Rule](https://forum.nginx.org/read.php?2,263698,263698#msg-263698)**
>
> Nginx redirect/rewrite Rule Old Url http://www.mydomain.com.br/forum/elsword-downloads-de-cheats-utilitarios/2369461-26-04-revolution-trainer-elsword.html 1. /forum/ - It is the folder that installed vbulletin 2....

---

<div class="post-metadata">

**Author:** ![Nginx\_Forum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ecc23a/32.png) [@Nginx\_Forum](https://www.ruby-forum.com/u/Nginx_Forum)\
**Post date:** [December 30, 2015, 6:05pm UTC](https://www.ruby-forum.com/t/nginx-redirect-rewrite-rule/243719/2 "2015-12-30T18:05:45Z")

</div>

On Sat, Dec 26, 2015 at 06:42:44AM -0500, Nginx Forum wrote:

Hi there,

> New Url  
> [http://www.mydomain.com.br/threads/26-04-revolution-trainer-elsword.2369461/](http://www.mydomain.com.br/threads/26-04-revolution-trainer-elsword.2369461/)
> 
> 1. /threads/ - the xenforo automatically add the address when accessing this  
> one topic.
> 2. 26-04-revolution-trainer-elsword - Topic name, even if the xenforo system  
> corrects’m wrong
> 3. 2369461 - Most importantly, the topic ID

Every request below /forum/ will be redirected (if it matches this  
pattern) or return 404 (if it does not). You may prefer to change the  
404 to return a redirect to /threads/, for example.

# === location ^~ /forum/ { location ~ ^/forum/[^/]_/([0-9]_)-(.\*).html$ { return 301 /threads/$2.$1/; } return 404; }

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
