两个方向的Nginx位置配置

两个方向的Nginx位置配置,nginx,configuration,location,Nginx,Configuration,Location,我有一点配置nginx服务器的经验,这是我的问题。 我正在尝试设置正确的位置。我有两个导演:address.com和address.com/api 对于最后一个方向(API),我已经设置了位置,效果很好。API位于/var/www/project/API文件夹中 root /var/www/project; index index.php; server_name localhost; location /api { try_files /api/$uri $uri/

我有一点配置nginx服务器的经验,这是我的问题。 我正在尝试设置正确的位置。我有两个导演:address.comaddress.com/api

对于最后一个方向(API),我已经设置了位置,效果很好。API位于/var/www/project/API文件夹中

root /var/www/project;
index index.php;
server_name localhost;

location /api {
            try_files /api/$uri $uri/ /api/index.php?$query_string;
            fastcgi_pass 127.0.0.1:9000;                
            fastcgi_split_path_info ^/api/(.+\.php)(/.+)$;
            fastcgi_intercept_errors on;
            fastcgi_index index.php;
            include fastcgi_params;
}
location ~ \.php$ {
            try_files $uri =404;
            fastcgi_keep_conn on;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_buffer_size 32k;
            fastcgi_busy_buffers_size 64k;
            fastcgi_buffers 4 32k;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    }
现在我需要将address.com的root实现为/var/www/project/website。在这里我遇到了一些麻烦

首先,我写的是:

 location / {
      alias /var/www/project/website/;
 }
然后我尝试添加了许多不同的变体,这是我最后一个注释

我已经把它放在位置/{}

       location ~ ^/(.+\.php)$ {
           alias /var/www/project/website/;
           include /etc/nginx/fastcgi.conf; 
           proxy_intercept_errors on;
           fastcgi_split_path_info ^(.+\.php)(.*)$;
           fastcgi_intercept_errors on;
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
   }
/etc/nginx/fastcgi.conf文件中,我添加了

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
我得到了所有时间403禁止404未找到或在nginx错误日志中写入,例如,/var/www/project/website/…

有人有nginx配置经验,并且知道如何设置/website位置正确吗?

类似的内容:

server {
    listen 80;
    server_name localhost;

    root /var/www/src/website;
    index index.php index.html;

    error_log  /var/log/nginx/error.log;

    location / {
        try_files $uri $uri/ =404;
    }
    location /test {
        try_files $uri $uri/test.html =404;
    }
    location /api/ {
        alias /var/www/src/api/;
        try_files $uri $uri/ /index.php =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }
    location /pmants {
        root /var/www/src/;
        index index.php index.html index.htm;
        location ~ ^/pmants/(.+\.php)$ {
                try_files $uri =404;
                root /var/www/src/;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }

        location ~* ^/pmants/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                root /var/www/src/;
        }
    }
    location ~* \.php {
        include fastcgi_params;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_cache off;
        fastcgi_index index.php;
    }
}