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


#1

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
        index.php
     - Slim
     - vendor
 index.html
  - js
  - css
  etc...

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]
</IfModule>

And other in rest/public:

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

The website is displayed correctly when I access example.com/, which is exactly what I want. But when I make any request to example.com/rest/public/… 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:

$app->get(
    '/test', 
    function (Request $request, Response $response) {
        return $response->withJson("works");
    }
);

Thank you very much!