Welcome! Log In Create A New Profile

Advanced

Re: Problem when using subfolder

Maxim Dounin
December 25, 2012 01:06PM
Hello!

On Tue, Dec 25, 2012 at 08:52:32AM -0800, Bill Culp wrote:

> ngnix docs state that the closest match will always be found in location phrases
>
> So why is alias needed?

Normally (with root specified) nginx constructs file name as
<root> + <uri>. This allows to specify root at any level, and it
will work without surprises via configuration inheritance. I.e.

root /path/to;

location /foo/ {
# ...
}

and

location /foo/ {
root /path/to;
}

and even

location /foo/ {
...
location /foo/bar {
root /path/to;
}
}

all will result in a "/foo/bar.txt" request being mapped into
a "/path/to/foo/bar.txt" file.

In contrast, alias replaces part of the URI matched by a location,
and file name will be <alias> + <uri-part-not-matched>. This is
more fragile as things change as you move the alias directive to
another place, but allows to map URI to file system if some parts
of the URI needs to be modified, e.g. in configuration like

location /foo/ {
alias /path/to/baz/;
}

request to "/foo/bar.txt" will be mappend into
"/path/to/baz/bar.txt" file.

It is generally recommended to use "root", except in situations
like thread starter has, i.e. when URI needs to be modified when
mapping to a file system.

See here for docs:

http://nginx.org/r/root
http://nginx.org/r/alias

[...]

--
Maxim Dounin
http://nginx.com/support.html

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

Problem when using subfolder

PascalTurbo December 25, 2012 11:04AM

Re: Problem when using subfolder

Maxim Dounin December 25, 2012 11:08AM

Re: Problem when using subfolder

Bill Culp December 25, 2012 11:54AM

Re: Problem when using subfolder

Maxim Dounin December 25, 2012 01:06PM

Re: Problem when using subfolder

Bill Culp December 25, 2012 11:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 299
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