首页 > 解决方案 > 使用 nginx 使用 root 和 index 设置位置

问题描述

嗨,我想知道为什么在我的 nginx 服务器上设置位置时总是收到 404 错误。以下是我正在尝试做的事情:

server {
        listen       80;
        server_name  localhost;

      
 location / {
            root   html;
            index  index.html index.htm;
        }
    
    }
location /api {
            root   html;
            index  index.html index.htm;
        }
    
    }

问题是 /api 位置调用。我只是在玩 ngnix,想知道为什么它找不到 html 文件。我认为这可能是root的问题。我需要设置的根和索引到底是什么才能使其在 / 位置路径中完全正常工作

标签: nginx

解决方案


推荐阅读