nginx 设置某个目录只允许访问指定后缀文件
server {
listen 80;
server_name your_domain.com;
location /example_directory/ {
# 允许访问 特定 后缀的文件
location ~* \.(png|jpg|jpeg|PNG|JPG|JPEG)$ {
allow all;
try_files $uri $uri/ =404;
}
# 拒绝其他所有请求
deny all;
}
# 其他配置...
}
