Hello guys,
We're struggling with fellow sysadmins with a lighhtpd->nginx/1.8.1 migration and rewrite rules.
We have an API and a rewrite rule like this (in nginx) :
rewrite ^/api/(.*)$ /api.php?action=$1 last;
In my PHP API, I split the "actions" in an array, with the explode PHP function.
Therefore, this:
GET /api/article/search&key=AUTHENTIFICATION_KEY&q=SEARCH_QUERY
rewrites to /api.php?action=article/search&key=AUTHENTIFICATION_KEY&q=SEARCH_QUERY
The PHP system array $_GET contains
"action'" => "article/search"
"key"=>"AUTHENTIFICATION_KEY"
"q"=>SEARCH_QUERY
So far so good... Except when there is a space in the search query, like this:
GET /api/article/search&key=AUTHENTIFICATION_KEY&q=SEARCH QUERY&blabla=lol&test=wes (last parameters given as examples)
I don't know why but in this case, the & character in the URL seems to be escaped. Therefore, my PHP $_GET array only has on field: the entire string after /api.
["action"] => "article/search&key=AUTHENTIFICATION_KEY&q=SEARCH QUERY&blabla=lol&test=wes"
and $_GET['ak'] and ['key'] are empty ...
Any idea?
Edited 1 time(s). Last edit at 02/24/2016 03:29PM by nerthazrim.