Why my route don't work?


I have this route
self::$app->get('/login', Login::class . ":get") ->setName('G_Login');

And he works when path “domain.com/login” and “domain.com/////login” and “domain.com////////////////////////////////////////login

How this fixed?

SlimFramework 4


Need more context, whats your project over look like? Why you calling self::$app…

Hows your container set up is the Login class registered there?


this Main class my app

and index.php

<? require __DIR__ . "/../../vendor/autoload.php"; Namespace\Main::main();


From what I can see you dont initiate a container. You refer to Login::class and the get method but slim 4 doesnt know where you’ve put it.

Try reviewing:

The problem is not in the operation of the controller. The problem is that it should work only with /login, but for some reason it works with ////////login

Adding this to your .htaccess fixes the issue, its not Slim related:

Options -Indexes

To prevent other duplicate slashes in the url you can also add this:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(([^/\ ]+/)*)/+([^\ ]*)
RewriteRule ^ /%1%3 [L,R=301]