1、子目录匹配 
如下配置

location / {
root /data/www;
}

  访问http://127.0.0.1/时,配匹配/data/www 
访问http://127.0.0.1/images时,配匹配/data/www/images 
访问http://127.0.0.1/images/1.jpg时,配匹配/data/www/images/1.jpg 
也就是说,地址栏里"/"后的路径是直接匹配目录data/www/下的路径

location /images/ {
root /data/www;
}

  访问http://127.0.0.1/images时,配匹配/data/www/images 
也就是说,地址栏里/images,直接匹配了/data/www的子目录. 
经常出问题的是,location里的url随意配了一个名字,如/xxx,但是对应的/data/www目录 
下并没有该/data/www/xxx子目录,一访问就404

2、重复路径匹配规则

server {
location / {
root /data/www;
} location /images/ {
root /data;
}
}

  访问URL http://localhost/images/example.png,将会匹配第二个/images/规则, 
虽然也可以匹配location /规则,但nginx默认会选择最长前缀去匹配当前URL,也就是 
第二个配置会生效,访问/data/images/目录,而不是/data/www/images/目录

 server {
listen 8888;
server_name localhost; location / {
root E:/nginx-1.13.6/html/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
} location /server/ {
proxy_pass http://xxxxxxx:8080/;
}
}

  

最新文章

  1. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  2. MySQL的数据类型
  3. 各类 HTTP 返回状态代码详解
  4. C++输入输出流
  5. DataTable使用技巧总结【转】
  6. iOS开发UI篇—UITableview控件简单介绍
  7. java集合类的学习总结一
  8. 03_汇编语言(n个数找最大值)
  9. 一些常用的linux命令
  10. JSON 字符串 与 java 对象的转换
  11. OWASP-ZAP
  12. 第 2 章 代理模式【Proxy Pattern】
  13. Eclipse3.7默认字体修改-找回Courser-New字体
  14. Hadoop学习之Hadoop案例分析
  15. File already exists: filesystem '/path/file', transaction svn常见错误解决方法
  16. ruby gsub gsub! chomp chomp! 以及所有类似函数用法及区别
  17. Java构造器练习题
  18. Ex 5_26 变量约束是否能同时满足(并查集)_第九次作业
  19. 模块化&os&sys
  20. tomcat单机多实例部署

热门文章

  1. springboot+mysql+mybatis+Mybatis-Generator+druid 项目demo
  2. vue面试题总结
  3. OSG开源教程(转)
  4. Python字符串的两种方式——百分号方式,format的方式
  5. 【intern】最长公共子串、编辑距离、KMP 等
  6. java--序列化和反序列化
  7. nyoj 633 幂
  8. vue搭建app, M端项目流程
  9. webDriver基本运用
  10. clearTimeout方法在IE上的兼容问题