Nginx rewrite infinite loop

António P. P. Almeida appa at perusio.net
Sun Jul 31 01:27:48 UTC 2011


On 29 Jul 2011 05h33 WEST, lists at ruby-forum.com wrote:

> Hi.
>
> I tried to rewrite all non-www url to www url, but when i tried to
> access the site, i got the infinite loop. following is my config
>
> server {
> server_name www.example.com;

> }
> location / {
> ......
>
> rewrite ^ http://example.com$request_uri? permanent;
> proxy_pass http://example.com
>
> }

>
>
> but if i change to redirect to the www url with locale(like, en,
> zh_CN), it works fine. following is the config.
>
> server {
> server_name www.example.com;
> }
>
> location / {
> ......
>
> rewrite ^ http://example.com/zh_CN$request_uri? permanent;
>
> }
>
> location ^~ /zh_CN {
> ........
>
> proxy_pass http://example.com
> }
>
>
> any help is appreciated.
>
> Thank You
>
>
> Steve

server {
  server_name www.example.com;

  location / {
     proxy_pass http://example.com;
  }

}


server {
    server_name *.example.com;

    rewrite ^ http://www.example.com$request_uri? permanent;
}

--- appa




More information about the nginx mailing list