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

**URL:** <https://discourse.slimframework.com/t/with-file-name-throwing-error-httpnotfoundexception-404-but-working-with-file-name/3884>\
**Category:** Questions\
**Created:** [February 23, 2020, 11:42am UTC](https://discourse.slimframework.com/t/with-file-name-throwing-error-httpnotfoundexception-404-but-working-with-file-name/3884 "2020-02-23T11:42:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitjain](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@amitjain](https://discourse.slimframework.com/u/amitjain)\
**Post date:** [February 23, 2020, 11:42am UTC](https://discourse.slimframework.com/t/with-file-name-throwing-error-httpnotfoundexception-404-but-working-with-file-name/3884/1 "2020-02-23T11:42:36Z")

</div>

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

> [@HttpNotFoundException not found](https://discourse.slimframework.com/t/httpnotfoundexception-not-found/3560):
>
> Hello, there was such an error “HttpNotFoundException not found” brief description: Type: Slim\Exception\HttpNotFoundException Code: 404 Message: Not found. File: …/Slim/Middleware/RoutingMiddleware.php Line: 91 Install: I installed the framework via composer, version 4.2 { “require”: { “slim/slim”: “4.2”, “slim/psr7”: “^0.5” }, “autoload”: { “psr-4”: { “App\”: “src/” } } } My Computer: PHP: version 7.2.19 use apache with version 2.4.29 (default config) index.php \<?php …

but could not work it out

will appreciate help on this.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [February 23, 2020, 8:05pm UTC](https://discourse.slimframework.com/t/with-file-name-throwing-error-httpnotfoundexception-404-but-working-with-file-name/3884/2 "2020-02-23T20:05:21Z")

</div>

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](https://odan.github.io/2019/11/05/slim4-tutorial.html#apache-url-rewriting)

You could also try this setup: [GitHub - selective-php/basepath: Base path detector for Slim 4](https://github.com/selective-php/basepath#installation)
