Mass virtual hosting and global redirect

Igor Sysoev is at rambler-co.ru
Mon Jun 15 22:47:25 MSD 2009


On Mon, Jun 15, 2009 at 12:22:39PM -0400, NoSync wrote:

> I could be wrong, but with your snippet I'd get domain.com redirected to www.domain.com, but also sub.domain.com redirected to www.sub.domain.com. Very possible I'm missing something here, though. :-)

   server {
         listen 80;
         server_name  ~^[^.]+\.[^.]+$;         # domain.com
         rewrite   ^  http://www.$host$request_uri?;
   }

   server {
         listen 80;
         server_name  www.*;                   # www.domain.com
         server_name  ~^[^.]+\.[^.]+\.[^.]+$;  # sub.domain.com
         ...
   }


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





More information about the nginx mailing list