0

I'm trying to implement a custom nginx error page in PHP, but it seems that my error handler will always show 200, rather than the status that was actually generated (e.g. 404 if I were to type an invalid link). Here's my error_page directive:

error_page 400 401 402 403 404 410 418 500 502 503 504 505 /scrnus.php;
location = /scrnus.php {
    root /var/www/error_pages;
    internal;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTPS on;
    fastcgi_pass scrnus-php;
}

Expected result: Expected result

Actual result: Actual result

Any help would be appreciated.

emberdex
  • 111
  • 2

1 Answers1

1

Ended up fixing the problem by passing the status as a GET variable to my script:

error_page 400 401 402 403 404 410 418 500 502 503 504 505 /scrnus.php?error=$status;

Not the nicest way of doing it, but it works and is invisible to the user.

emberdex
  • 111
  • 2