关于localtion 下的root和alias的区别

这篇文章写的很好。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访问

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值