Skip to content

properly pass query parameters for URLs that do not correspond to a PHP file

Fridtjof requested to merge (removed):fridtjof/fix-query into master

Query parameters were not properly passed to FastCGI/PHP on URLs that did not exist as a file.

In https://gitlab.com/foodsharing-dev/images/-/blob/35b976a3c1e501953de3ab49a6a1744eb5c18f38/web/app.conf#L60, the following line:

try_files $uri $uri/ /index.php;

will try accessing any file in the project directory specified by $uri. If it does not find one, it will just use /index.php as the request URI instead (!). Because query parameters are part of the URI, they get lost here, so nginx's $query_string is empty in those cases. FastCGI's QUERY_STRING is populated by this variable, which in turn gets used to generate $_GET in PHP.

This is fixed trivially for both web and web_ci (see 4c4f5f05). $args contains the query string, if any, and $is_args contains a '?' if the query string is not empty.

Edited by Fridtjof

Merge request reports