Nginx location 使用正则匹配路径

Nginx location 使用正则匹配路径

配置方式

~~* 加正则表达式

~* [正则表达式] 不区分大小写

~ [正则表达式] 区分大小写

例子

server {
	listen 80;
	
	# 匹配.xml结尾的文件 不区分大小写
	# url不区分大小写但访问test.XML匹配不到test.xml文件
	location ~* \.(xml)$ {
		root /usr/share/nginx/files/seo/;
	}
	
	# 匹配robots.txt文件
	location ~ robots.txt$ {
		root /usr/share/nginx/files/seo/;
	}
}

你可能感兴趣的:(Nginx,nginx,java,服务器)