Slim 3 cannot work in a subdirectory by default.
Here I will show you a simple soultion to run multiple Slim applications under Apache.
The directory skeleton structure:
C:\xampp\htdocs\slim3-app
-- config
---- container.php
-- public
---- .htaccess
---- index.php
-- vendor
-- .htaccess
slim3-app/.htaccess
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
slim3-app/config/container.php
Add this fix to the container:
<?php
// ...
$container['environment'] = function () {
$scriptName = $_SERVER['SCRIPT_NAME'];
$_SERVER['REAL_SCRIPT_NAME'] = $scriptName;
$_SERVER['SCRIPT_NAME'] = dirname(dirname($scriptName)) . '/' . basename($scriptName);
return new Slim\Http\Environment($_SERVER);
};
Now just open the application: http://localhost/slim3-app
Apache, XAMPP, PHP, Slim Framework