Locations with regex

Hello all, Igor,
First of all, congrats Igor for nginx, the most enlightened and
powerful web server/proxy i’ve used. My notebook doesn’t swap any more
:wink:
I’m having some problem with regexed location in my config, and can
catch it.
I have a named server and 2 (or more) subdirs that represent php
apps, those apps have some url rewrite rules, so as a lazy programmer, i
like to define a flexible location rule to map all my apps subdirs
(app1|app2|…), but it seems like the rule is not matched.
two conf examples:

    location /app1/ {
        root   /home/website/beta.ws/webroot/;
        index  index.php index.html index.htm;
        include  /etc/nginx/cakephp_rewrite_rules;
    }

    location /app2/ {
        root   /home/website/beta.ws/webroot/;
        index  index.php index.html index.htm;
        include  /etc/nginx/cakephp_rewrite_rules;
    }

works ok, but something like:

    location ^~ /(app1|app2)/ {
        root   /home/website/beta.ws/webroot/;
        index  index.php index.html index.htm;
        include  /etc/nginx/cakephp_rewrite_rules;
    }

doesn’t…
i’ve read http://wiki.codemongers.com/NginxHttpCoreModule#location but
didn’t get any progress…

any help is wellcome.

On Mon, 22 Oct 2007 18:58:40 -0200
Alejandro V. [email protected] wrote:

[snip]

works ok, but something like:

    location ^~ /(app1|app2)/ {

[snip]

doesn’t…
i’ve read http://wiki.codemongers.com/NginxHttpCoreModule#location but

From that very page:

The second is to use the prefix ^~. This prefix is used with a
conventional string and tells nginx to not check regular expressions
if the path provided is a match.

^~ does not signify a regex. It is a simple string, and just says not
to search the regexes. You want “~”, possibly “~ ^/(app1|app2)/”.