too many redirects

Igor Sysoev igor at sysoev.ru
Thu Oct 6 06:34:56 UTC 2011


On Wed, Oct 05, 2011 at 08:32:52PM -0700, seminal wrote:
> I'm following the wiki's guidelines with:
> 
>    server {
>    server_name mike.example.com;
>    rewrite ^ http://www.example.com$request_uri? permanent;
> }
> 
> I'm getting a "this page has too many redirects error".  So I tried:
> 
> location = example.com { rewrite example.com www.example.com permanent; }

This location has no sense from nginx point of view.

> This worked after I had gone to www.example.com but if I clear the cache and
> first go to example.com (like a first-time user) I get a "DNS lookup
> failed."
> 
> Any suggestions, thanks.

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

server {
    server_name www.example.com;
    ...
}


-- 
Igor Sysoev



More information about the nginx mailing list