一、空格:默认匹配、普通匹配
location / { root /home; }
二、= :精确匹配(表示匹配到 /home/resources/img/face.png 这张图片)
location = /resources/img/face.png { root /home; }
三、~*:匹配正则表达式,不区分大小写
四、~:匹配正则表达式,区分大小写
#GIF必须大写才能匹配到 location ~ .(GIF|jpg|png|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/997836.html