You cannot delete the second route $app->get('/') , since this is the default route, and it’s normal to get 404, because $app->get('/:name', function ($name) {}) expects an argument to the feedback function 'name' , which is missing.
You are trying to do the following:
http://localhost/mysite/ --- Outputs Hello World http://localhost/mysite/marcosh --- Outputs a 404 ??
If so, then, as a77icus5 suggested, we may need to look into your htacess file and what is the structure of the project structure ...
I have a fresh Slim Skeleton , and I decided to share my configuration with you ...
The directory of my web project is as follows:
Webroot -htaccess - public -- htaccess -- assets --- js --- css - templates - app - vendor -- Slim -- Twig
In the first .htaccess located in the root directory of the project, I added:
<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/$1 [L] </IfModule>
Here public corresponds to the name of the application’s public folder
Then in the .htaccess located in the shared folder, I added:
<IfModule mod_php5.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] </IfModule>
Then in SLIM -> Environment.php (line 142 - Virtual Path) and try changing as follows:
// Virtual path // $env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path $env['PATH_INFO'] = str_replace(str_replace('/public', "", dirname($_SERVER['PHP_SELF'])), '', "/".$requestUri); // remove public from URI $env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string $env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash