Regular expressions in server_name: pattern length

Igor Sysoev igor at sysoev.ru
Wed Dec 9 15:58:18 MSK 2009


On Wed, Dec 09, 2009 at 04:55:41AM -0800, Michael Shadle wrote:

> cool!
> 
> I only use captures in one place but this might make things nicer. Is
> that $domain accessable to anything inside of that server {} block?

Yes.

> even something inside of an include for example?

Yes.

> On Wed, Dec 9, 2009 at 4:53 AM, Igor Sysoev <igor at sysoev.ru> wrote:
> > On Wed, Dec 09, 2009 at 04:51:33AM -0800, Michael Shadle wrote:
> >
> >> On Wed, Dec 9, 2009 at 4:49 AM, Igor Sysoev <igor at sysoev.ru> wrote:
> >>
> >> > Named server_name captures can be used since 0.8.25.
> >>
> >> What do you mean by 'named'
> >
> > server {
> >    server_name   ~^(www\.)?(?<domain>.+)$;
> >
> >    location / {
> >        root  /sites/$domain;
> >    }
> > }


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



More information about the nginx mailing list