"root" directive weirdness
Dennis J.
dennisml at conversis.de
Fri Jan 22 15:53:27 MSK 2010
On 01/22/2010 01:45 AM, Marcus Clyne wrote:
> Hi,
>
> Cliff Wells wrote:
>> On Thu, 2010-01-21 at 22:10 +0100, Dennis J. wrote:
>>> Hi,
>>> 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 reason why you're having problems is the 'last' tag on the rewrite,
> which will end the rewrite rules and then look for the corresponding URL
> (which sends it back to the first location). Using 'break' instead would
> prevent this, and do as you expect. However, for this situation, the
> second regex is an unnecessary waste of processing.
Once the server configuration is complete it will be much more complex than
the one above. That was only a simplified example to illustrate the
problem. I didn't now that a "last" would send nginx back to the location
stage of processing. With that in mind the processing makes sense of
course. Thanks for the explanation!
Regards,
Dennis
More information about the nginx
mailing list