NGINX 位置与精确 URL 匹配

NGINX 位置与精确 URL 匹配
server {
    listen 80;
    server_name test.com www.test.com;

    set $base_root /var/www/test;
    root $base_root;

    access_log  /var/www/test/frontend/runtime/log/access.log;
    error_log   /var/www/test/frontend/runtime/log/error.log;

    charset utf-8;
    client_max_body_size 128M; ## listen for ipv4

    client_body_buffer_size     32k;
    client_header_buffer_size   8k;
    large_client_header_buffers 8 64k;

    index index.php index.html;

    set $_bootstrap "index.php";

    location / {
    
        root $base_root/frontend/web;
        try_files $uri $uri/ /frontend/web/index.php$is_args$args;
        
        location ~ ^/assets/.+\.php(/|$) {
            deny all;
        }
        
    }

    location /cabinet/ {
        alias $base_root/app/;
        index    index.html;
        try_files $uri $uri/ /index.html$args;
                
             
    }
}

我想要以“/cabinet/”开头的所有内容,打开 app/index.html “app”是一个目录 /var/www/test/app

如果我写了 /cabinet/ 它可以工作,但如果写了 /cabinet/test 则不行,它匹配“location /”

相关内容