The root and alias nginx

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/lyl0724/article/details/92984129

root alias can be defined and the location module, are used to specify the actual path of the requested resource, such as:

location /i/ {
  root /data/w3;
}

Request http: //XXX/i/top.gif when this address, the real resources on the server which corresponds /data/w3/i/top.gif file
Note: the real value of root path is specified add location the specified value.

The alias as its name, alias specified path location is an alias, no matter how the value of location to write the true path of the resource are alias specified path, such as:

location /i/ {
  alias /data/w3/;
}

The same request http: when //XXX/i/top.gif, look at the server resource path is: /data/w3/top.gif

Other differences:
1, Alias can only act in location, whereas there may be root server, http and location in.
2, behind the alias must use the "/" end, otherwise it will not find the file, but the root of "/" non-essential.

Guess you like

Origin blog.csdn.net/lyl0724/article/details/92984129