Nginx directives not running concurrently

Hello,

Some data on the site are sent with Ajax, and the “.php” extension is not available at the end of these links. E.g; https://panel.example.com/app/controller/ajax/collect

At the same time, there is no “.php” suffix at the end of the site-wide pages.

I am able to send data without the “.php” at the end with Ajax. Like this;

try_files $uri/ $uri.html $uri.php$is_args$query_string;

it works. However, rewrite does not work with the above code:

rewrite ^/([^/]+)/([^/]+)?$ /index.php?cmd=$1&scd=$2 last;
rewrite ^/([^/]+)/?$ /index.php?cmd=$1 last;

Sample link: https://panel.example.com/detail/prd1234

As a result, the above codes are correct and working but not working at the same time. How can I run these two codes at the same time?

Server: Nginx 1.18

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.