Many PHP frameworks suggest to add this to nginx :
location / {
try_files $uri /index.php$is_args$args;
}
to execute index.php
on all HTTP requests.
Why do I need $is_args$args
? I think the $args
are already in the HTTP GET request. So why does nginx need to pass them that way to index.php?
It depends on who wrote index.php
. A large number of parameters are sent to PHP from nginx
, and usually QUERY_STRING and REQUEST_URI are among them.
If the programmer accesses $_SERVER["QUERY_STRING"]
they will receive whatever was appended to the end of /index.php
in the try_files
statement.
If the programmer accesses $_SERVER["REQUEST_URI"]
they will receive the original URI together with the original query string, and anything appended to the end of /index.php
in the try_files
statement will not affect that.
The two applications that I host (WordPress and MediaWiki) obviously use the latter, because I do not append $is_args$args
to the /index.php
and it all works fine.
But another application may behave differently.