【发布时间】:2022-01-15 10:08:53
【问题描述】:
我有以下目录方案
/srv/www/htdocs/www/
其中 www 是公共目录根目录,而 htdocs 包含公共访问之外的文件。这是 nginx.conf
server {
listen 443 ssl http2;
root /srv/www/htdocs/www;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}
error_page 401 @errorPage;
error_page 403 @errorPage;
error_page 404 @errorPage;
location @errorPage {
root /srv/www/htdocs;
rewrite ^ error.php?error=$status last;
}
}
我要做的是在 401,403 和 404 触发时提供 error.php 页面,但我仍然得到默认的 Nginx 404 页面,即使我以编程方式触发 403 或 401。
我在指定位置做错了吗?
【问题讨论】:
标签: php nginx nginx-location