Apache / NginX passing request as PHP get variable

This is a very simple one, kinda works like rewriting. All page path requests will be passed to PHP though $_GET[‘page’]. Not the greatest implementation, but it works, and it works well. Everything else works as you would expect it.

To pass all requests inside /directory to /directory/index.php as ?page=/request

site configuration
location /directory {
    index index.php;
    try_files $uri $uri/ /directory/index.php?page=$uri&$args;
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?page=%{REQUEST_URI}&%{QUERY_STRING} [L]

So if I request:
NginX will pass it (in the background) to
and the $_GET superglobal in index.php will be equivalent to:

array {
    'page'  => '/2017/january/25',
    1       => 2,
    3       => 4