wildcard to rewritre multi domains to www
brianmercer
nginx-forum at nginx.us
Sun Sep 6 08:00:43 MSD 2009
Try
server {
listen 80;
server_name ~^[^.]+\.[^.]+$; # domain.com
rewrite ^ http://www.$host$request_uri?;
}
from http://forum.nginx.org/read.php?2,2924,2936#msg-2936
testbot Wrote:
-------------------------------------------------------
> That goes rewrites to http://www..com/
>
>
> -----Original Message-----
> From: owner-nginx at sysoev.ru On Behalf Of
> Cliff Wells
> Sent: Saturday, September 05, 2009 3:13 PM
> To: nginx at sysoev.ru
> Subject: RE: wildcard to rewritre multi domains to
> www
>
> Try this:
>
> server {
> server_name ~(^.+\..+$);
> set $name $1;
> rewrite ^ http://www.$name$request_uri?
> permanent;
> }
>
> Regards,
> Cliff
>
> On Sat, 2009-09-05 at 11:28 -0500, AMP Admin
> wrote:
> > Thanks. I'll do that. I was just hoping that I
> wouldn't have to list all
> > domains. That works though. :)
> >
> > Regards,
> >
> > -Team AMP
> > http://www.ampprod.com
> >
> > -----Original Message-----
> > From: owner-nginx at sysoev.ru On Behalf Of
> Igor
> > Sysoev
> > Sent: Saturday, September 05, 2009 9:21 AM
> > To: nginx at sysoev.ru
> > Subject: Re: wildcard to rewritre multi domains
> to www
> >
> > On Sat, Sep 05, 2009 at 08:57:57AM -0500, AMP
> Admin wrote:
> >
> > > Hi, I would like to rewrite several domains to
> from .example.com to
> > > www.example.com. I think the best way is to
> use a wild card. Too bad I
> > > suck at rewrite rules. Haha
> > >
> > > Can someone help me make the following work?
> > >
> > > if ($host != 'www.*.com') {
> > > rewrite ^/(.*)$
> http://www.*.com/$1 permanent;
> > > }
> >
> > server {
> > server_name
> ~^((?:domain1|domain2|domain3)\.com)$;
> > set $name $1;
> > rewrite ^
> http://www.$name$request_uri? permanent;
> > }
> >
> >
> --
> http://www.google.com/search?q=vonage+sucks
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5672,5692#msg-5692
More information about the nginx
mailing list