Nginx 500 error page is not working with matches any unmatched URL -


in nginx conf. error 500 rule not working location conf. lines below.

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; } 

the error.html file in /path/to/nginx directory. when create 500 error in code, couldn't run nginx 500 rule. if remove location / { part, , change 500 404, works.

edit:

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;     }  } 


Comments