在我的Nginx conf中。错误500规则不适用于位置conf。以下几行。
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规则。 如果我删除位置/ {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;
}
}