我的NGinx配置存在问题,我知道已有很多主题,但我没有设法正常工作......

所以我有mydomain.com和mydomain.com/api/,我的文件夹就像:/var/www/mydomain.com/website/dist和/var/www/mydomain.com/api/public

而目前,我的工作几乎正常 . 但是index.php仍然在我的路由中得到/ api部分 .

server {
    listen 80;
    server_name mydomain.com www.mydomain.com;

    index index.php index.html;

    location / {
        root /var/www/mydomain.com/website/dist;
    }

    location ~ ^/api(/|$) {
        root /var/www/mydomain.com/api/public;
        try_files $uri /api/index.php;

        location ~ \.php$ {
            try_files $uri /index.php =404;

            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index           index.php;
            fastcgi_pass            unix:/tmp/php5-fpm.sock;
            include                 fastcgi_params;
            fastcgi_param           SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param           APPLICATION_ENV production;
        }

        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Content-Type,Authorization';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
    }

    access_log /var/logs/nginx/logs/mydomain.com-access.log;
    error_log /var/logs/nginx/logs/mydomain.com-error.log;
}

我想我不了解位置或php-fpm . 我错过了什么 ?我该怎么做才能让它正常工作?

我也读到了一个try_file,而不是重写规则......我不知道:/

谢谢您的帮助 !