Here is the rule in English:
Any HTTP request other than those for index.php, assets folder, files folder and robots.txt is treated as a request for your
You want to do this instead:
if ($request_uri !~ ^/(index\.php|assets|files|robots\.txt)) {
rewrite ^/(.*)$ /index.php/$1 last;
}
$request_uri is for the original URI request by the client. If you want the URI request AFTER other Nginx rewrite rules have processed it then you would use $uri. However, for what you are trying to do the prior would be the one you would want.
Also, you need to escape special regular expression characters like .
by using a backslash.