参见英文答案 > How can I get around using alias in nginx? 1个
当我尝试在位置/ api / v1使用带有?$args的try_files时,我得到错误404.没有它它正常工作.任何的想法?
Nginx配置
server {
listen 80;
server_name domain.com;
index index.PHP;
root /home/ec2-user/dev.domain.com.br/webroot/default/web;
location / {
try_files $uri $uri/ /index.PHP?$args;
}
location ~ \.PHP${
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
location /api/v1 {
alias /home/ec2-user/dev.domain.com/webroot/apiv1/web;
# Works,but don't parse args.
try_files $uri /api/v1/index.PHP; ## << WORKING
# Do not work. Error 404.
try_files $uri /api/v1/index.PHP?$args; ## << ERROR
location ~ \.PHP${
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
}
最佳答案
There are issues当你一起使用try_files和alias指令时.
原文链接:https://www.f2er.com/nginx/435220.html