我有以下服务器配置:
server {
listen 80;
server_name _;
root /var/www/;
location /calendars/ {
autoindex on;
try_files $uri.ics $uri =404;
}
}
Run Code Online (Sandbox Code Playgroud)
如果希望autoindex在访问时获得页面http://example.com/calendars/,但是我得到一个404 File not found错误。
我希望服务器做这样的伪代码:
if($uri is directory) {
if(one of index pages exists in directory) {
show index page;
} else {
show autoindex page;
}
} else {
if($uri.ics exists) {
show $uri.ics;
} else if($uri exists) {
show $uri;
} else {
show 404 page;
}
}
Run Code Online (Sandbox Code Playgroud)