一、空格:默认匹配、普通匹配

location / {
root /home;
}

二、= :精确匹配(表示匹配到  /home/resources/img/face.png 这张图片)

location = /resources/img/face.png {
root /home;
}

三、~*:匹配正则表达式,不区分大小写

#符合图片的显示
location ~* .(GIF|jpg|png|jpeg) {
root /home;
}

四、~:匹配正则表达式,区分大小写

#GIF必须大写才能匹配到
location ~ .(GIF|jpg|png|jpeg) {
root /home;
}

五、^~:以某个字符路径开头

location ^~ /resources/img {
root /home;
}

六、

server {
listen 90;
server_name localhost; location / {
root /home/foodie-shop;
index index.html;
} ##一、利用原路径访问
location /imooc {
root /home;
} ##二、利用起别名的方式、访问 给resources起了个别名static
location /static {
alias /home/resources;
} }

Nginx配置文件nginx.conf中location的匹配原则的更多相关文章

  1. Nginx 中 location 的匹配顺序

    nginx中location的匹配模式有以下几种: 精确匹配:以=开头,只有完全匹配才能生效,例子location = /uri 非正则匹配:以^~开头,^表示非.~表示正则,例子location ^ ...

  2. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  3. Nginx配置文件 nginx.conf 和default.conf 讲解

    nginx.conf /etc/nginx/nginx.conf ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; ...

  4. Nginx 配置文件nginx.conf中文详解

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  5. Nginx配置文件nginx.conf详细说明

    Nginx配置文件nginx.conf详细说明 #worker_processes 8; #worker_cpu_affinity 00000001 00000010 00000100 0000100 ...

  6. Nginx配置文件nginx.conf中文详解【转】

    PS:Nginx使用有两三年了,现在经常碰到有新用户问一些很基本的问题,我也没时间一一回答,今天下午花了点时间,结合自己的使用经验,把Nginx的主要配置参数说明分享一下,也参考了一些网络的内容,这篇 ...

  7. tomcat的配置文件server.conf中的元素的理解

    tomcat的配置文件server.conf中的元素的理解 tomcat作为一个servlet服务器本身的配置文件是tomcat_home/conf/server.conf,这个配置文件中有很多元素, ...

  8. linux下Nginx配置文件(nginx.conf)配置设置详解(windows用phpstudy集成)

    linux备份nginx.conf文件举例: cp /usr/local/nginx/nginx.conf /usr/local/nginx/nginx.conf-20171111(日期) 在进程列表 ...

  9. 004-mac上安装以及Nginx 配置文件nginx.conf详解

    1.mac上nginx安装 安装brew:go-001-环境部署,IDEA插件 安装nginx: brew search nginx brew install nginx 当然也可以编译安装 安装完以 ...

  10. nginx配置文件nginx.conf 不包括server节点

    整理的一个nginx.conf的配置,不包括server节点介绍 原文请查看,Nginx配置文件(nginx.conf)配置详解 # For more information on configura ...

随机推荐

  1. NOIP2023游寄

    Day -?? 模拟赛挂分. Day -18 模拟赛挂大分,挂分大于得分.(180/400,得分/标准分,下同) 连着挂了好多场了,感觉有点迷茫了. Day -17 模拟赛--AK了?(400/400 ...

  2. 前端scale负数表示翻转

    https://blog.csdn.net/wang_yu_shun/article/details/121299208 极力推荐这个博主写的,前端有关负数的小技巧

  3. Spring源码阅读 ------------------- SpringFrameWork 5.2 +IDEA 部署其他坑位问题(二)

    一.地址下jar包无法下载问题   报错信息:      Could not get resource 'https://plugins.gradle.org/m2/org/asciidoctor/o ...

  4. ansible功能实现

    模糊匹配远程主机文件并拉取到本地服务器 又熬夜加班了.花很长时间研究出来.如何实现模糊匹配到的远程文件批量拉取到本地的剧本.使用copy模块的*,shll模块的* ls|grep XX都没有实现,貌似 ...

  5. vulnhub靶场 --> JANGOW: 1.0.1

    靶机下载地址 JANGOW: 1.0.1 << 点我下载 开始打靶 IP发现 nmap扫描网段发现靶机ip:192.168.111.140 端口发现 对靶机进行常规端口扫描 访问网站 访问 ...

  6. Linux运维面试总结

    1.Linux系统相关日志 /var/log/message:系统信息日志,包含错误信息 /var/log/secure:系统登录日志 /var/log/maillog:邮件日志 /var/log/c ...

  7. 将python文件转换成exe可执行文件

    一.安装Pyinstaller pip install pyinstaller(Pyinstaller) 二.找到 .py文件的路径并执行如下命令 pyinstaller -F 要转换的文件.py 三 ...

  8. iOS技术管理思路

    iOS技术管理思路

  9. Vue3使用Composition API实现响应式

    title: Vue3使用Composition API实现响应式 date: 2024/5/29 下午8:10:24 updated: 2024/5/29 下午8:10:24 categories: ...

  10. 卡方分布和 Zipf 分布模拟及 Seaborn 可视化教程

    卡方分布 简介 卡方分布是一种连续概率分布,常用于统计学中进行假设检验.它描述了在独立抽样中,每个样本的平方偏差之和的分布.卡方分布的形状由其自由度 (df) 参数决定,自由度越大,分布越平缓. 参数 ...