Google News
logo
Slim Framework - Interview Questions
How to Running in a sub-directory in Slim Framework?
This example assumes that the front controller is located in public/index.php.
 
To “redirect” the sub-directory to the front-controller create a second .htaccess file above the public/ directory.
 
The second .htaccess file should contain this code:
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
You may also set the base path so that the router can match the URL from the browser with the path set in the route registration. This is done with the setBasePath() method.
$app->setBasePath('/myapp');
Advertisement