Nginx virtual directory (the difference between alias and Root)

Source: Internet
Author: User

Original address: http://blog.sina.com.cn/s/blog_6c2e6f1f0100l92h.html

Nginx virtual directory (the difference between alias and Root)today configuration awstats,awstats created file directory under/home/awstats, in nginx add configuration after 404, found or ignore the difference between Root and alias, will modify the configuration record as follows: 1. Failure: server {
server_name test.com;
CharSet utf-8,gb2312;
Index index.html; Location/{
root HTML;
Access_log Logs/access.log Main;
}
Location ~ ^/awstats/{
root/home/awstats/;
Index index.html;
Access_log off;
Error_log off;
CharSet gb2312;
} 2. Failure: server {
server_name test.com;
CharSet utf-8,gb2312;
Index index.html; Location /{
root HTML;
Access_log Logs/access.log Main;
}
Location ~ ^/awstats/{
alias/home/;
Index index.html;
Access_log off;
Error_log off;
CharSet gb2312;
}  3. Success: server {
server_name test.com;
CharSet utf-8,gb2312;
Index index.html; Location /{
root HTML;
Access_log Logs/access.log Main;
}
Location ~ ^/awstats/{
alias/home/awstats/;
Index index.html;
Access_log off;
Error_log off;
CharSet gb2312;
} 4. Success: server {
server_name test.com;
CharSet utf-8,gb2312;
Index index.html; Location /{
root HTML;
Access_log Logs/access.log Main;
}
Location ~ ^/awstats/{
root/home/;
Index index.html;
Access_log off;
Error_log off;
CharSet gb2312;
}from the above example, it is clear that the concept of root and alias has been mixed ~1. Location ~ ^/awstats/{
root/home/awstats/;
Access:http://test.com/awstats/ The actual access is/home/awstats/awstats/ 2. Location ~ ^/awstats/{
alias/home/ access:http://test.com/awstats/ The actual access is/home/ 3. Location ~ ^/awstats/{#使用alias时目录名后面一定要加 "/"
alias/home/awstats/; access:http://test.com/awstats/ The actual access is/home/awstats/ 4. Location ~ ^/awstats/{
root/home/;Visit: http://test.com/awstats/ The actual access is/home/awstats/
Borrow Ayou Teacher's sentence:
In general, configuring alias in Location/other is a good habit to configure root in location/

Nginx virtual directory (the difference between alias and Root)

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.