Regular expressions in server_name: pattern length

Maxim Dounin mdounin at mdounin.ru
Fri Feb 5 01:56:19 MSK 2010


Hello!

On Thu, Feb 04, 2010 at 02:50:11PM -0800, Michael Shadle wrote:

> i'm on 0.8.33 now
> 
> server_name ~^(?<domain>.+)\.domain\.com$;
> 
> [emerg]: pcre_compile() failed: unrecognized character after (?< in
> "^(?<domain>.+)\.domain\.com$" at "domain>.+)\.tianocore\.org$" in
> /etc/nginx/nginx.conf

Congratulations, level up! :)

Either upgrade pcre library to 7.0 at least, or use (?P<...>) 
syntax as available from pcre version 4.0.

BTW, you may read the same thing here:

http://nginx.org/en/docs/http/server_names.html#regex_names

Maxim Dounin

> 
> 2010/2/4 Maxim Dounin <mdounin at mdounin.ru>:
> > Hello!
> >
> > On Thu, Feb 04, 2010 at 02:10:05PM -0800, Michael Shadle wrote:
> >
> >> I'm trying this right now:
> >>
> >> server {
> >>    listen 80;
> >>    server_name ^(?<domain>.+)(\.mydomain\.com)$;
> >>    rewrite ^ http://foo.net/script/index.php?title=$domain permanent;
> >> }
> >>
> >> also tried
> >>
> >>    server_name ^(?<domain>.+)\.mydomain\.com$;
> >
> > -    server_name ^(?<domain>.+)\.mydomain\.com$;
> > +    server_name ~^(?<domain>.+)\.mydomain\.com$;
> >
> >>
> >> it says unknown variable $domain
> >>
> >> it's 0.8.24. also tried 0.8.33.
> >
> > 0.8.25+
> >
> > Maxim Dounin
> >
> >>
> >> [emerg]: unknown "domain" variable
> >>
> >> Any help? :)
> >>
> >> 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/
> >> >
> >> > _______________________________________________
> >> > nginx mailing list
> >> > nginx at nginx.org
> >> > http://nginx.org/mailman/listinfo/nginx
> >> >
> >>
> >> _______________________________________________
> >> nginx mailing list
> >> nginx at nginx.org
> >> http://nginx.org/mailman/listinfo/nginx
> >
> > _______________________________________________
> > nginx mailing list
> > nginx at nginx.org
> > http://nginx.org/mailman/listinfo/nginx
> >
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx



More information about the nginx mailing list