nginx如何设置子目录

How to set subfolder in nginx

我正在尝试将 html 文件夹中的 index.php 文件设置为 localhost:5555,并将 html/highlighter 文件夹中的第二个 index.php 文件设置为 localhost:5555/highlighter 第一个一切正常,但第二个不行,当我去 localhost:5555/highlighter 它打印 404 Not Found
你能帮帮我吗?
我的文件夹树:

nginx
│ 
├── html
│   ├── 50x.html
│   ├── highlight
│   │   ├── functions.php
│   │   ├── icon.png
│   │   ├── index.css
│   │   ├── index.php
│   └── index.php
├── nginx.exe

nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server {
        listen       5555;
        server_name  localhost;

        location / {
            root   html;
            index  index.php;
        }
        
        location /highlighter {
            root html/highlight;
            index index.php;
        }
        
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9123;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

更新
我的错误是在位置块中添加了 2 个根,如果你有同样的错误,请尝试像这样从位置块移动根

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       5555;
        server_name  localhost;

        root   "D:\Miscellaneous\nginxSites";
        
        location / {
            index  index.php;
        }
        
        location /highlighter {
            index  index.php;
        }
        
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9123;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

您可以尝试以下方法:

location /highlighter {
            alias /var/www/html/highlighter/;
                index index.php index.html;
                #try_files $uri $uri/ =404;
                try_files $uri $uri/ /highlighter/index.php;
        }