Welcome! Log In Create A New Profile

Advanced

Re: map module regular expression help

Dick Middleton
August 26, 2011 12:06PM
On 08/26/11 13:02, Igor Sysoev wrote:
> 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;
>> }

> Wiki is wrong here. Currently nginx does not support expression
> in value part, you may use only a single variable, i.e.:

I thought that might be it ;-)

What I'm trying to do is make my config file more elegant. I have quite a
number of subdirectories which all have their own document root. So there's a
location for each and each has to have an alias and a php proxy. I was trying
to coalesce them.

So I tried:

map $uri $locn {
/sub1 /locn1;
/sub2 /locn2;

...
}

index index.php;
location ~ ^/(sub1|sub2 etc ) {
alias $locn;

location ~ \.php$ {

}
}

but it doesn't work. fastcgi can't find the file. One symptom is that
$request_filename is not set to the full path; i.e the index.php part is missing.

It works OK if I put a literal in the alias rather than the same value from a
mapped variable.

Is this construct supported?

There's another problem I don't understand

If I have

index index.php;

location /sub1 {
alias /path1;
...
}

It looks for /path1/index.php as expected but if I change location to regex

location ~ ^/sub1

then it looks for /path1 with no index.

Dick



_______________________________________________
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: 310
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