Nested .htaccess file

Hi,

Running into some difficulty with slim running in a subfolder consisting of nested .htaccess files.

=project
== app
=== .htaccess (#1)
=== web
==== subfolder
===== .htaccess (#2)
===== index.php (Slim App)

As in above, I point my web root in apache to project/app. Inside the “app” folder I have an .htaccess (#1) file that re-writes the url to prepend /web

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(subdomain.)?domain$
RewriteCond %{REQUEST_URI} !^/web/  
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /web/$1
RewriteCond %{HTTP_HOST} ^(subdomain.)?domain$
RewriteRule ^(/)?$ web/index.php

No, in the subfolder (where I am running a slim app) I have another .htaccess file using the standard one provided by slim.

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

In my slim app, I have a route (e.g. testRoute) which does not resolve. It will only resolve if I prepend the route with /subfolder like below:

DOESN’T WORK - Returns 404

$app->get("/testRoute", function ($request, $response, $args) {
     return $response;
});

WORKS

$app->get("/subfolder/testRoute", function ($request, $response, $args) {
     return $response;
});

Also, if I access it directly, (e.g. http://site/web/subfolder/testRoute) it works fine (without the /subfolder/testRoute route), which leads me to believe it’s something in the .htaccess file. Any thoughts on how the .htaccess files need to be set up so that it works as envisioned?