Both root and alias can be defined in the location module, and are used to specify the real path of the requested resource, such as:
location /i/ { root /data/w3; }
Request http://foofish.net/i/top. gif
This address, then the corresponding real resource in the server is /data/w3/i/top.gif
File
Note: True The path is the value specified by root plus the value specified by location.
And alias is just like its name. The path specified by alias is the alias of location. No matter how the value of location is written, the real path of the resource is the path specified by alias. , for example:
location /i/ { alias /data/w3/; }
http://foofish.net/i/top.gif, the resource path searched on the server is:
/data/ w3/top.gif
Other differences:
1. alias can only be used in location, while root Can exist in server, http and location.The above is the detailed content of What is the difference between the root and alias directives in Nginx configuration?. For more information, please follow other related articles on the PHP Chinese website!