With file name throwing error: HttpNotFoundException / 404 But working with file name

i am working wamp my local machine url is 127.0.0.1/slim/

i have just currently installed default available
versions of slim framework 4.XX

It works : 127.0.0.1/slim/ : I get response “hello world”

It does not work : 127.0.0.1/slim/index.php :
Type: Slim\Exception\HttpNotFoundException /404

It does not work : 127.0.0.1/slim/randomfilename :
Shows Apache error of 404

i have following : require DIR . ‘/vendor/autoload.php’;
i have set base path in the index.php = $app->setBasePath("/slim");

I also tried few things in


but could not work it out

will appreciate help on this.

Hi @amitjain

It does not work : 127.0.0.1/slim/index.php
It does not work : 127.0.0.1/slim/randomfilename

This is ok and should not work, because it’s not a valid and defined route for slim.

$app->setBasePath("/slim");

This is also good.

Please read this section about Slim 4 and Apache URL rewriting

You could also try this setup: https://github.com/selective-php/basepath#installation