Ext.: https://www.ttlsa.com/nginx/nginx-root_alias-file-path-configuration/
Summary: Alias changes the access path. Root corresponds to the first/alias of the location match position corresponding to the last/
Example: Root/var/www alias/var/ttt/location match/a/access/a/b/a.html root corresponding result/var/www/a/b/a.html alias corresponding result/var/ttt/b /a.html.
NGINX Specifies the file path there are two ways to root and alias, the usage of the difference between the use of methods summarized under, convenient for everyone in the application process, rapid response. The main difference between Root and alias is how Nginx interprets the URI behind the location, which causes the two to map the request to the server file in different ways.
[Root]
Syntax: Root path
Default value: Root HTML
Configuration segment: HTTP, server, location, if
[Alias]
Syntax: Alias path
Configuration segment: Location
Instance:
123456 |
location ~ ^/weblogs/ { root /data/weblogs/www. Ttlsa. COM; autoindex on; auth_basic "Restricted"; auth_basic_user_file passwd/weblogs; } |
If the URI of a request is/weblogs/httplogs/www.ttlsa.com-access.log, the Web server will return the/data/weblogs/www.ttlsa.com/weblogs/on the server The Httplogs/www.ttlsa.com-access.log file.
[Info]root is mapped according to the full URI request, which is/path/uri. [/info]
Therefore, the previous request map is Path/weblogs/httplogs/www.ttlsa.com-access.log.
123456 |
location ^~ /binapp/ { limit_conn limit 4; limit_rate 200k; internal; alias /data/statics/bin/apps/; } |
Alias discards the path that is configured behind the location, pointing to the directory that is currently matched to the specified directory. If the URI of a request is/binapp/a.ttlsa.com/favicon, the Web server will return the/DATA/STATICS/BIN/APPS/A.TTLSA.COM/FAVICON.JGP file on the server.
[WARNING] 1. When using alias, be sure to add "/" after the directory name.
2. Alias can specify any name.
3. Alias when using a regular match, you must capture the content to match and use it at the specified content.
4. Alias can only be located in the location block. [/warning]
Nginx Root&alias File path configuration