gpt4 book ai didi

nginx - 如何强制自动索引并忽略index.html 文件

转载 作者:行者123 更新时间:2023-12-01 18:16:26 30 4
gpt4 key购买 nike

当nginx使用autoindex服务目录时,它会列出文件,但是当index.html存在时,浏览器将加载该文件。我希望它忽略它。

server {
listen 80;
server_name herbert;

location / {
root /srv/www;
index index.htm index.html;
add_header Cache-Control no-cache;
expires 300s;
}

location /site-dumps/ {

root /srv/www/;
autoindex on;
}
}

最佳答案

这是不可能的。您应该移动其他目录中的其他文件并在index.html 中创建一个iframe。

类似的事情:

index.html

<iframe src="/site-dumps_files"></iframe>

nginx.cnf

server {
listen 80;
server_name herbert;

location / {
root /srv/www;
index index.htm index.html;
add_header Cache-Control no-cache;
expires 300s;
}

location /site-dumps/ {
root /srv/www/;
}

location /site-dumps_files/ {
root /srv/www/;
autoindex on;
}
}

希望对您有用。

关于nginx - 如何强制自动索引并忽略index.html 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28166131/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com