if (!-e $request_filename) { rewrite ^/app/(\w+)/(.*)$ /app/$1/index.php?s=/$2 last; rewrite ^/(.*)$ /index.php?s=/$1 last; }