Nginx 500错误页面无法处理任何不匹配的URL
在我的Nginx配置中,错误500规则不适用于下面的位置配置行Nginx 500错误页面无法处理任何不匹配的URL,nginx,nginx-location,Nginx,Nginx Location,在我的Nginx配置中,错误500规则不适用于下面的位置配置行 location / { try_files $uri $uri/ @rewrite; } error_page 500 /error.html; location = /error.html { root /path/to/nginx; internal; } location @rewrite{ rewrite ^ /index.php?q=$uri; } error.html文件位于/path/to/ng
location / {
try_files $uri $uri/ @rewrite;
}
error_page 500 /error.html;
location = /error.html {
root /path/to/nginx;
internal;
}
location @rewrite{
rewrite ^ /index.php?q=$uri;
}
error.html文件位于/path/to/nginx目录中。
当我在代码中创建一个500错误时,它无法运行Nginx 500规则。
如果我删除location/{part,并将500更改为404,它就会工作
编辑:
将整个文件与服务器{}一起发布整个文件与服务器{}
server {
listen 80;
listen 443 ssl;
server_name_in_redirect off;
port_in_redirect off;
server_tokens off;
server_name www-dev.somc.io;
root /path/to/site;
index index.php index.html index;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;
error_page 500 /error.html;
location = /error.html {
root /usr/share/nginx/html;
internal;
}
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite{
rewrite ^ /index.php?q=$uri;
}
add_header Cache-Control no-cache;
set $skip_cache 0;
set $cache_control max-age=660;
location ~ \.php$ {
include /etc/nginx/php-handler.conf;
fastcgi_pass hhvm;
}
}