# Redirect ends up in a loop

**URL:** <https://www.ruby-forum.com/t/redirect-ends-up-in-a-loop/190893>\
**Category:** NGINX\
**Created:** [June 30, 2010, 9:46am UTC](https://www.ruby-forum.com/t/redirect-ends-up-in-a-loop/190893 "2010-06-30T09:46:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shainp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@shainp](https://www.ruby-forum.com/u/shainp)\
**Post date:** [June 30, 2010, 9:46am UTC](https://www.ruby-forum.com/t/redirect-ends-up-in-a-loop/190893/1 "2010-06-30T09:46:31Z")

</div>

Hello!

I wanted to use NginxHttpMapModule and NginxRedirect to redirect static  
links to dynamic php links.

I want to redirect http://my\_domain/static/static\_page1.html to  
http://domain\_name/dynamic/zone.php?zoneid=86 by looking up the url from  
a map table.

I tried this but it ends in a redirect loop.

```
[code]

```

map\_hash\_bucket\_size 256;  
map $uri $dynamic\_url {  
default 42;  
/static/static\_page1.html 86;  
/static/static\_page2.html 36;  
}  
server {  
listen 80;  
server\_name \_;  
rewrite ^  
http://domain\_name/dynamic/zone.php?zoneid=$dynamic\_url break;  
}  
[/code]

Please help me with this.  
Regards,  
Shain

Posted at Nginx Forum:

> **[Redirect ends up in a loop](https://forum.nginx.org/read.php?2,103815,103815#msg-103815)**
>
> Hello! I wanted to use NginxHttpMapModule and NginxRedirect to redirect static links to dynamic php links. I want to redirect http://my\_domain/static/static\_page1.html to http://domain\_name/dynamic/zone.php?zoneid=86 by looking up the url from a map...

---

<div class="post-metadata">

**Author:** ![shainp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3d9bf3/32.png) [@shainp](https://www.ruby-forum.com/u/shainp)\
**Post date:** [June 30, 2010, 10:18am UTC](https://www.ruby-forum.com/t/redirect-ends-up-in-a-loop/190893/2 "2010-06-30T10:18:43Z")

</div>

On Wed, Jun 30, 2010 at 03:45:27AM -0400, shainp wrote:

> ```
> rewrite ^
> 
> ```
> 
> http://domain\_name/dynamic/zone.php?zoneid=$dynamic\_url break;  
> }  
> [/code]

Do you want to proxy or redirect ?

- rewrite ^ http://domain\_name/dynamic/zone.php?zoneid=$dynamic\_url  
break;

- rewrite ^ http://domain\_name/dynamic/zone.php?zoneid=$dynamic\_url;

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
