NGINX配置:访问/1时输出指定文件内容 (不使用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/n4ja 著作权归作者所有。请勿转载和采集!