rewrite catch all subdomain

Igor Sysoev is at rambler-co.ru
Mon Mar 10 19:55:33 MSK 2008


On Mon, Mar 10, 2008 at 05:48:13PM +0100, Pedro Axl wrote:

> Thank You Denis,
> 
> It's strange, If I enter directly on domain.com:8080 I receive an error 
> (of the Firefox): "The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for this 
> address in a way that will never complete."
> 
> If I enter www.domain.com:8080 I am redirected to domain.com:8080 and I 
> got that error.
> 
> But if I go to anything.domain.com:8080 I receive the "Server not found" 
> error.

     server {
         listen  8080;
         server_name   domain.com;
         ...
     }

     server {
         listen  8080 default;
         server_name   *.domain.com;

         rewrite ^ http://mydomain.com:8080$uri last;
     }

> 
> 
> 
> Denis S. Filimonov wrote:
> > Try this:
> > 
> > location / {
> >     rewrite .* http://mydomain.com:8080$uri last;
> > }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list