In your case, you can use root
directive, because $uri
part of the location
directive is the same with last root
directive part.
Nginx documentation advices it as well:
When location matches the last part of the directive’s value:location /images/ { alias /data/w3/images/; }
it is better to use the root directive instead:
location /images/ { root /data/w3; }
and root
directive will append $uri
to the path.