location uri 添加 / 和不添加 / 的区别?

#不添加/,默认上/code/test目录下找index.html文件,如果没有 index.html则会查找/code/test文件
location /test {
    root /code;
    index index.html;
}
	
#添加/,默认上/test目录下寻找index.html文件,如果没有index.html 则会直接返回404 
location /test/ {
    root /code;
}

#示例测试代码
[root@oldxu code]# cat /etc/nginx/conf.d/uri.oldxu.net.conf 
	server {
    listen 80;
		server_name uri.oldxu.net;
		root /code;

	#	location /test {
	#		index index.html;
	#	}

		location /test/ {
			index index.html;
		}
	}
别妄自尊大! 别妄自菲薄! QQ技术交流群:Linux架构师之路~ 471443208
原文地址:https://www.cnblogs.com/oldxu/p/15128917.html