我为我的服务器设置了静态错误页面,但我想忽略那些以 开头的 url,/api/以便处理程序可以使用非 200 代码进行响应,但不返回静态错误页面。
这是现有的配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com;
root /var/www/html/;
index index.php;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_intercept_errors on;
fastcgi_index app.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
}
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location ^~ /error/ {
root /usr/share/nginx/html/;
}
}
Run Code Online (Sandbox Code Playgroud)
所以我想我想添加一个新位置,例如:
location /api/ {
}
Run Code Online (Sandbox Code Playgroud)
但我不确定用什么来告诉它不遵循服务器的 error_page 规则。
nginx ×1