首页 > 解决方案 > Nginx 位置未解析

问题描述

我试图让我的 nginx 实例主机来自两个单独的静态文件。

根路径的配置有效,但使用任何其他前缀模式会导致 404 未找到。

配置如下:

server {
    listen       80;
    server_name  *.saurabhharwande.com;
    root         /var/www/certbot;

    location /abc/ {
        index  vindex.html;
    }

    location / {
        root  /usr/share/nginx/html;
        index index.html index.htm;
    }
}

www.saurabhharwande.com作品

www.saurabhharwande.com/abc给 404

我错过了什么吗?

编辑:我对 nginx 配置工作原理的基本理解是有缺陷的。我认为索引文件是在根本身 /<domain>/<root>/index.html 中搜索的,并且位置仅用于指向不同的根。而是在 <domain>/<root>/<location>/index.html 进行搜索

标签: nginxnginx-locationnginx-config

解决方案


推荐阅读