NGINX访问1时输出文件ahtml的内容不要使用try_files
可以使用NGINX的location指令来实现这个需求。具体配置如下:
server {
listen 80;
server_name example.com;
location /1 {
alias /path/to/a.html;
index index.html;
}
}
解释一下上面的配置:
location /1指令表示匹配访问路径为/1的请求。alias /path/to/a.html指令表示将请求映射到/path/to/a.html文件。index index.html指令表示如果请求路径末尾没有指定具体文件名,则默认访问index.html文件。
这样配置后,当访问example.com/1时,NGINX会将请求映射到/path/to/a.html文件,并将该文件的内容返回给客户端。
原文地址: https://www.cveoy.top/t/topic/fbCg 著作权归作者所有。请勿转载和采集!