In the controller inside /my/app/uri. If I echo out $_SERVER['QUERY_STING'] it should be empty but I get /my/app/uri as a result. How to fix this? I never happens to me before.
Because if I get value via \Input::server('QUERY_STRING') from non fast CGI there is no URI in it. But if I get this from fast CGI there is URI in it. It should return the same value.
The values in $_SERVER reflect your environment, there are more values that are different whether or not you use FastCGI. $_SERVER['QUERY_STRING'] contains the query string that is passed on to PHP by FastCGI, so it is correct. It wouldn't work if it had different contents.
I'm writing a comment on this old thread because it's the only one I can find on the subject and it seems it wasn't really solved.
In my opinion, the FuelPHP behavior of modifying the Query String is wrong. I'm using FuelPHP 1.8.
I am using Fast CGI on Windows (dev) and FPM with mod_proxy_fcgi on Linux (prod) and on both systems the Query String gets modified (as coded in .htaccess). Let's see the example of environment variables, which are the same on both environments:
- $_SERVER['QUERY_STRING'] = /transactions&test=1 (wrong, should be "test=1")
Can you explain why the QUERY_STRING is modified inside .htaccess? It should be the same for every environment. I know there was some troubles with correct path for CGI installs, but I don't see this is the case.
To support my argument I can say, that this causes problems with built-in FuelPHP pagination as the QUERY_STRING gets looped.
I changed the .htaccess value:
From: RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
To: RewriteRule ^(.*)$ index.php [L]
And everything is working like a charm on both: FastCGI and FPM with PROXY_FCGI, which is probably the best way to run PHP at the moment.
So I need a think about how to address this problem, and not create yours.
The reason for that (odd) rewrite btw is because there are combinations of Apache en php-fpm versions that do not pass the QUERY_STRING, so this is why it is reconstructed in the Input class.