NGINX的自定义PHP错误页面无响应'?= _'

I've recently created a custom error page with configuration such as:

error_page 404 /error.php?code=404

But it seems to show up only error.php instead of error.php?code=404.

I've cheked the php file by accessing /error.php?code=404 in my browser and it works fine. I am using $Get

Please help. Thanks a lot.

From the nginx documentation it seems that you can specify only an URI of script name (or @named location), not its parameters. I guess the script receives the parameters of the original URI instead.

There are several solutions/workarounds:

1) You need to have a separate errorXYZ.php script for each error code you want to redirect.

2) Or use external redirect such as http://yourserver.com/error.php?code=404, but note that this will be defaut reply with HTTP response code 302 and the users will see the error.php location in their browser.

3) Or URIs such as /error.php/404 and parse it inside your PHP script.