On Tuesday 01 October 2013 11:12:41 Grant wrote: > >> It works if I specify the full path for the alias. What is the > >> difference between alias and root? I have root specified outside of > >> the server block and I thought I could use alias to avoid specifying > >> the full path again. > > > > http://nginx.org/en/docs/http/ngx_http_core_module.html#alias > > http://nginx.org/en/docs/http/ngx_http_core_module.html#root > > > > The docs says that the requested filepath is constructed by concatenating > > root + URI > > That's for root. > > > > The docs also say that alias replaces the content directory (so it must > > be absolutely defined through alias). > > By default, the last part of the URI (after the last slash, so the file > > name) is searched into the directory specified by alias. > > alias doesn't construct itself based on root, it's totally independent, > > so by using that, you'll need to specify the directory absolutely, which > > is precisely what you wish to avoid. > > I see. It seems like root and alias function identically within "location /". >
Not exactly. For example, request "/favicon.ico": location / { alias /data/www; } will result in opening "/data/wwwfavicon.ico", while: location / { root /data/www; } will return "/data/www/favicon.ico". But, location / { alias /data/www/; } will work the same way as location / { root /data/www; } or location / { root /data/www/; } wbr, Valentin V. Bartenev _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx