在服务器中未启用Nginx重写

I have to change the configuration of the nginx so that, index.php in the public_html folder handles all the requests other than files and folders.

I know how to do this in htaccess

like this

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]

And when I searched, I found this code in nginx config file would do the same.

location / { 
try_files $uri $uri/ /index.php?$args; 
}

And I did set this up in the configuration file.

However, the home page works just fine, but, the other routes such as www.example.com/login does not work.

But, example.com/index.php/login shows the content of www.example.com/login

What could be wrong in this case ?

I am very new to nginx and only have very little knowledge in it.

Could anyone help ?

You can rewrite it like this:

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php?path=$1 last;
    break;
}