Map capture doesn't work?

Maxim Dounin mdounin at mdounin.ru
Fri Feb 3 14:52:53 UTC 2012


Hello!

On Fri, Feb 03, 2012 at 07:37:44PM +0700, Edho Arief wrote:

> Taken directly from example[1]:

This example is incorrect.

> 
> map $uri $new {
>   default               http://www.domain.com/home/;
> 
>   /aa                   http://aa.domain.com/;
>   /bb                   http://bb.domain.com/;
>   ~^/cc/(?P<suffix>.*)$ http://animebsd.net/$suffix;
>   /john                 http://my.domain.com/users/john/;
> }
> 
> server {
>   server_name   yutsuki.myconan.net;
>   rewrite  ^    $new   redirect;
> }
> 
> Accessing http://yutsuki.myconan.net/cc/whatever redirects to
> http://animebsd.net/$suffix ($suffix literal).

Map directive currently supports *variable* (single one) as a 
second parameter, but not a string with variables.  I.e. this will 
work:

    map $uri $new {
        ~^/cc/(?P<suffix>.*)$   $suffix;
    }

but the above doesn't.

Maxim Dounin



More information about the nginx-devel mailing list