添加configuration来处理不同位置的请求

我使用cakephp作为我的项目。我在/ etc / hosts中创build了本地dns文件夹,位于/var/sites.My,nginxconfiguration看起来像

location /{ add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; root /var/sites/$host/app/webroot; index index.php index.html; } 

在cakephp 3.x中,index.php的位置是/var/sites/$host/webroot。如何处理不同项目中index.php多个位置的场景。

根据需要定义多个位置块

 location /app1/ { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; root /var/sites/$host/app1/webroot; index index.php index.html; } location /app2/ { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; root /var/sites/$host/app2/webroot; index index.php index.html; }