这篇文章写的很好。https://www.cnblogs.com/my_life/articles/7070805.html
下面是该文章的内容
我实际应用
我要访问 C:\javaweb\apache-tomcat-8.5.45\apache-tomcat-8.5.45\webapps\ROOT目录下的index.html文件。下面是分别介绍使用root和alias如何配置localtion。
假设 server_name 是www.abc.com
1、使用root
location /ROOT{
root "C:/javaweb/apache-tomcat-8.5.45/apache-tomcat-8.5.45/webapps";
index index.html;
}
上面代码中
1、location 后面必须为root路径下面的子目录名,也可以是 /
2、# 路径的双引号加不加都可以
3、路径的斜杠可以反着也可以,就是这样
C:\javaweb\apache-tomcat-8.5.45\apache-tomcat-8.5.45\webapps
访问时通过 www.abc.com/ROOT访问
2、使用alias
location /home{
alias C:/javaweb/apache-tomcat-8.5.45/apache-tomcat-8.5.45/webapps/ROOT/;
index index.html;
}
1、下面home哪里可以写成任意的值,作为代理的“虚拟路径”。
访问时通过 www.abc.com/home访问