Welcome! Log In Create A New Profile

Advanced

Re: map module regular expression help

August 26, 2011 08:04AM
On Fri, Aug 26, 2011 at 12:47:55PM +0100, Dick Middleton wrote:
> Hi,
>
> In the wiki for the map module (http://wiki.nginx.org/HttpMapModule) the
> following is given as an example:
>
> map $uri $myvalue {
> /aa /mapped_aa;
> ~^/aa/(?<suffix>.*)$ /mapped_bb/$suffix;
> }
>
>
> The second form, the regex, I can't get to work - it returns the literal text
> rather than substituting for $suffix.
>
> from my map block:
>
> map $uri $locn {
> ~^/pdns(?<suffix>.*)$ /var/www/pdns$suffix;
> }
>
> the I rewrite:
>
> rewrite ^ $locn;
>
> from the log:
>
> open() "/var/www/pdns$suffix" failed
>
> How do I get this to substitute?
>
> This is using nginx/1.1.0 on debian squeeze.

Wiki is wrong here. Currently nginx does not support expression
in value part, you may use only a single variable, i.e.:
~^/pdns(?<suffix>.*)$ $suffix;

However, this wiki example is very ineffectual, because it maps $uri to path
forcing to use "rewrite". There are other simple ways to this, for example:

location /pdns {
root /var/www;
}

or (wiki expample):

location = /aa {
alias /mapped_aa;
}

location /aa/ {
alias /mapped_bb/;
}


--
Igor Sysoev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

map module regular expression help

Dick Middleton August 26, 2011 07:50AM

Re: map module regular expression help

Igor Sysoev August 26, 2011 08:04AM

Re: map module regular expression help

Dick Middleton August 26, 2011 12:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 294
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready