"root" directive weirdness

Dennis J. dennisml at conversis.de
Fri Jan 22 00:10:34 MSK 2010

I'm trying to configure a vhost where in the default case I want it to get 
the files from /opt/nginx/html but when the uri starts with "/users/" I 
want to to deliver the files from /web/users/ instead:

         location / {
             root   /opt/nginx/html;
             index  index.html index.htm;

         location ~* ^/users/ {
             root   /web/users;
             rewrite ^/users(/.*) $1 last;

The problem is that when I access "/users/index.html" the second location 
matches and the rewrite rule gets applied but the "root" directive is 
ignored and instead the one from the first location section is applied 
resulting in the delivery of the file "/opt/nginx/html/index.html".
Am I getting something wrong about the location/root directives or is this 
a problem with nginx?


More information about the nginx mailing list