I need to redirect all request for php files regardless of the subpath
so eg.
example.com/xx/y.php or example.com/xx/anotherpath/yy.php
it should remove /xx/ from the path
so it should rewrite to
example.com/y.php or example.com/anotherpath/yy.php
Please try out below code :)
server {
...
location ~ /.+/.+/.+\.php {
rewrite /.+/(.+)/(.+)\.php /$1/$2.php break;
}
location ~ /.+/.+\.php {
rewrite /.+/(.+)\.php /$1.php break;
}
location ~ .*\.php {
##your php processing code
}
...
}
You need to maintain the order of the above location blocks.