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)