Correctly remove routing url from query string.

It mostly happens when in nxing setups, because of location defined like:

try_files $uri $uri/ /app/webroot/index.php?$uri&$args;
Update tests.
Fix trailing whitespace.
Merge pull request #2694 from bar/patch-3

Correctly remove routing url from query string.