root works, alias doesn't

Grant emailgrant at gmail.com
Sun Sep 29 17:33:31 UTC 2013


> Absolute vs Relative paths.
> The log file line says it all: '/webalizer/index.html' doesn't exist, which
> is not the path of the file you wanna serve...
>
> Take a look at the following examples showing how 'location' address is
> replaced or completed (depending on absolute or relative 'alias' directive)
> by 'alias' path:
> http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

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://stackoverflow.com/questions/10084137/nginx-aliaslocation-directive

I tried both of the following with the same result:

location / {
    alias webalizer/;
}

location ~ ^/$ {
    alias webalizer/$1;
}

- Grant



More information about the nginx mailing list