如何设置nginx位置

如何设置nginx位置,nginx,Nginx,这是我的问题 我最近在学习nginx 我不知道为什么我可以处理我的位置配置 这是我的nginx.conf server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; root /Users/billyliou/web-site; location / { root

这是我的问题

我最近在学习nginx

我不知道为什么我可以处理我的位置配置

这是我的nginx.conf

server {
    listen       8080;
    server_name  localhost;


    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    root /Users/billyliou/web-site;

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

    location /demo {
        index  index.html index.htm;
        try_files $uri $uri/ /demo/index.html?s=$uri&$args;
    }

    location /test {
        index  index.html index.htm;
        try_files $uri $uri/ /test/index.html?s=$uri&$args;
    }
...
我将两个文件夹放入“/Users/billyyou/web站点”

一个是演示,另一个是测试

两者都包含index.html

当我输入localhost:8080时,它会显示nginx默认页面。 当我输入localhost:8080/demo时,它会显示demo页面。 但当我键入localhost:8080/test时,它也会显示演示页面。 最后一个超出了我的预料

如何设置此配置?

试试这个

server {
    listen       8080;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location /demo {
        root    /Users/billyliou/web-site/demo;
        index   index.html index.htm;
        try_files $uri $uri/ /index.html?s=$uri&$args;
    }

    location /test {
        root    /Users/billyliou/web-site/test;
        index   index.html index.htm;
        try_files $uri $uri/ /index.html?s=$uri&$args;
    }

    location / {
        root    /Users/billyliou/web-site;
        index   index.html;
    }

    ...
}