我已使用别名设置了 nginx,并尝试使用 try_files 执行重写规则。问题是它预先设置了文档根目录,但找不到文件。配置:
server {
listen 80;
server_name mysite.com;
root /var/www/default;
index index.html index.htm index.php;
location /coolapp {
alias /home/myhome/coolapp/www/;
index index.php;
try_files $uri $uri/ /home/myhome/coolapp/www/index.php?url=$uri&$args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
}
nginx 错误日志中:
[error] 21903#0: *2 open() "/var/www/default/home/myhome/coolapp/www/index.php" failed (2: No such file or directory) ...
为什么在 try_files 中将根添加到前面?我希望将别名视为其自己的根。我在这里做错了什么?