linux系统下nginx访问不区分大小写具体怎么配置
时间: 2023-08-19 18:09:54 浏览: 72
要让 Nginx 在 Linux 系统下访问不区分大小写,需要在 Nginx 配置文件中添加以下配置:
```
server {
listen 80;
server_name example.com;
server_name_in_redirect off;
port_in_redirect off;
ignore_invalid_headers on;
location / {
# 不区分大小写
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
# 忽略大小写
if_modified_since before;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
expires off;
etag off;
# 处理请求
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
```
这里,关键是在 location 中添加了 autoindex on 和 if_modified_since before 这两个配置,前者是开启自动索引,后者是强制使用 HTTP/1.0 协议,这样可以让 Nginx 不区分大小写。