Slim framework .htaccess in subfolder (don't work)

I’m not clear on this from .htaccess and there is no way it works.

I have the following structure on my server:

- htdocs
  - rest
     - public
     - Slim
     - vendor
  - js
  - css

In the folder htdocs I have the web page that consists of some html and js, and in the folder rest an apicacion with SlimFramework.

I only have one .htaccess in the rest folder, it contains:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(restSlim) rest/public/index.php [QSA,L]

And other in rest/public:

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteRule ^ index.php [QSA,L]

The website is displayed correctly when I access, which is exactly what I want. But when I make any request to… I get a 404. I understand that they are trying to access the file and this is not happening to RewriteRule. What do I do wrong?

In case I do wrong, I also put an example path:

    function (Request $request, Response $response) {
        return $response->withJson("works");

Thank you very much!