#不添加/,默认上/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;
		}
	}

相关文章:

  • 2022-12-23
  • 2021-05-10
  • 2022-03-08
  • 2022-12-23
  • 2021-10-29
  • 2021-07-25
猜你喜欢
  • 2021-09-15
  • 2022-02-24
  • 2021-09-27
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案