Nginx Root&alias File path configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.