Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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  domain_name;
            rewrite ^ http://domain_name/dynamic/zone.php?zoneid=$dynamic_url break;

Please help me with this. Regards, Shain

share|improve this question
rewrite ^/static http://domain_name/dynamic/zone.php?zoneid=$dynamic_url break;
share|improve this answer

What's most likely happening there is that you do not have a server block for domain_name. Since you use server_name _ it will catch all requests that do not have a more specific server block.

So Nginx gets the request, rewrites it, then gets the request in the same server block and your infinite loop has begun.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.