wildcard to rewritre multi domains to www
Cliff Wells
cliff at develix.com
Mon Sep 7 03:42:16 MSD 2009
On Sun, 2009-09-06 at 22:23 +0300, Marcus Clyne wrote:
> Hi,
>
> Cliff Wells wrote:
> > On Sat, 2009-09-05 at 23:53 +0300, Marcus Clyne wrote:
> >
> >> Hi,
> >>
> >> Cliff Wells wrote:
> >>
> >>> Try this:
> >>>
> >>> server {
> >>> server_name ~(^.+\..+$);
> >>> set $name $1;
> >>> rewrite ^ http://www.$name$request_uri? permanent;
> >>> }
> >>>
> >>>
> >>>
> >> That will cause problems if the domain begins with www. If you want to
> >> capture both www.domain.tld and domain.tld and rewrite to include the
> >> www., you could use
> >>
> >
> > That's odd, as I tested it and it worked fine ;-) It specifically does
> > not match domains starting with any subdomain,
> I think if you look at your regex again, you'll see that it's not that
> it doesn't match any domains with sub domains, it matches any domains
> with a dot somewhere in the middle. The \. guarantees that there's a
> dot, but the other characters can be anything.
Ah, so instead of .+ it'd need to be [^.]+ as in:
server_name ~(^[^.]+\.[^.]+$);
Cliff
--
http://www.google.com/search?q=vonage+sucks
More information about the nginx
mailing list