Nginx 404 error page php with params

.htaccesshttp-status-code-404nginx

In Opencart, 404 error is shown in this url: /index.php?route=error/not_found
This page has a 404 custom page with the template of all the website.

I´ve tried in Nginx with:

error_page 404 = /index.php?route=error/not_found;

But it goes to nginx 404 error page. If I only write:

error_page 404 = /index.php;

It goes to the index, but I don´t want to go to the index, I want to go to 404 opencart page.

I´ve also tried with a named location, and inside a rewrite, but I couldn´t get it working:

error_page 404 = @error;

location @error {
rewrite ^.*$ /index.php?route=error/not_found last;
}

It also doesn´t work. It goes to nginx 404 error page

Best Answer

Ok, I found the problem. fastcgi_intercept_errors was on, and nginx was intercepting the errors... it seems obviously now. I changed to fastcgi_intercept_errors off, and now is working perfect.