Analysis of the difference between directive Root and alias in Nginx configuration _nginx

Source: Internet
Author: User

Objective

When you recently deployed the Log Analysis tool Awstats on Nginx, when configuring Awstats analysis results for web browsing, Analysis results page access is always 404. Later looked at some data, found that the use of root and alias difference did not understand the cause, here specifically will be the difference between the two detailed way, for everyone to learn reference.

Both Root and alias can be defined in the location module, which is used to specify the true path of the requested resource, such as:

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

http://foofish.net/i/top.gif when requesting this address, the real resource in the server is the /data/w3/i/top.gif file

Note: The true path is the value specified by root plus the value specified by location.

And the alias, like its name, alias specifies a path that is location alias, regardless of how the value of the location is written, the true path of the resource is the path specified by the alias , such as:

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

At the same request http://foofish.net/i/top.gif , the resource path that is found at the server is: /data/w3/top.gif

Other differences:

1, the alias can only function in location, and root can exist in the server, HTTP and location.

2, the alias must be followed by the "/" end, or you will not find the file, and root is "/" optional.

Summarize

The above is the entire content of this article, I hope to be able to learn or work to bring certain help, if you have questions you can message exchange

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.