我有php应用程序,由三部分分隔:前端,后端,api。我需要将子域映射到这样的根:
我当前的nginx配置:
server {
listen 80;
server_name ~^(?<subdomain>(api|frontend|backend))\.domain\.com$ domain.com;
if ($subdomain = '') {
set $subdomain 'frontend';
}
root /var/www/domain/$subdomain/www;
index index.php;
access_log /var/log/nginx/domain.access.log;
error_log /var/log/nginx/domain.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}