Grant
October 02, 2013 12:24PM
>> >> 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/;
> }

That's true. Is alias or root preferred in this situation for performance?

- Grant

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

root works, alias doesn't

Grant September 25, 2013 02:16PM

Re: root works, alias doesn't

B.R. September 25, 2013 02:28PM

Re: root works, alias doesn't

Grant September 29, 2013 01:34PM

Re: root works, alias doesn't

B.R. September 29, 2013 03:22PM

Re: root works, alias doesn't

Grant October 01, 2013 03:14AM

Re: root works, alias doesn't

Valentin V. Bartenev October 01, 2013 10:10AM

Re: root works, alias doesn't

Grant October 02, 2013 12:24PM

Re: root works, alias doesn't

Valentin V. Bartenev October 02, 2013 02:24PM

Re: root works, alias doesn't

Grant October 02, 2013 03:04PM

Re: root works, alias doesn't

Valentin V. Bartenev October 01, 2013 09:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 293
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready