这有效:
location ~ ^/special/(.+\.php)$ {
alias /var/special/$1;
try_files "" =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; # php-fpm socket
}
但这不会:
location ~ ^/special/(.+\.php)$ {
alias /var/special/$1;
try_files "" =404;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000; # php-fpm socket
fastcgi_cache mycache;
}
如果我尝试访问 URL“/special/index.php”,我会得到“找不到文件”。浏览器中的文本,我假设它来自 php-fpm 或 PHP。我在 Nginx 日志中收到此错误:
FastCGI sent in stderr: "Primary script unknown", client: 202.179.27.65, server: myserver.org, request: "GET /special/index.php HTTP/1.1", host: "myserver.org"
知道为什么添加 fastcgi_cache 会破坏这一点吗?
请注意,当我使用不使用别名的位置时,fastcgi_cache 可以正常工作。