# 404 New Install

**URL:** <https://discourse.slimframework.com/t/404-new-install/3356>\
**Category:** Questions\
**Created:** [August 15, 2019, 8:46pm UTC](https://discourse.slimframework.com/t/404-new-install/3356 "2019-08-15T20:46:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 15, 2019, 8:46pm UTC](https://discourse.slimframework.com/t/404-new-install/3356/1 "2019-08-15T20:46:48Z")

</div>

Im having issues getting the routes to work. I just did new install of Slim Skeleton

when I go to localhost/newsite/public/users/1 I get 404.

Any suggestions on what to check?

I get no Apache errors. mod\_rewrite looks to be good.  
.htaccess seems to working fine

| statusCode | 404 |
| --- | --- |
| error | |
| type | “RESOURCE\_NOT\_FOUND” |
| description | “Not found.” |

---

<div class="post-metadata">

**Author:** ![Antnee](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Antnee](https://discourse.slimframework.com/u/Antnee)\
**Post date:** [August 15, 2019, 8:56pm UTC](https://discourse.slimframework.com/t/404-new-install/3356/2 "2019-08-15T20:56:07Z")

</div>

This is going to depend a lot on how you’ve configured your site, but I would expect that it’s available on [http://localhost/users/1](http://localhost/users/1)

Have you configured your routes to require a trailing slash?

Does it work if you try the site’s homepage?

What does the route pattern look like?

---

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 16, 2019, 12:30am UTC](https://discourse.slimframework.com/t/404-new-install/3356/3 "2019-08-16T00:30:31Z")

</div>

my apache public html dir is located /var/www/html

slim is located in /var/www/html/newsite

I have not “configured” anything.

I just did a composer install of slim skeleton

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [August 16, 2019, 10:53am UTC](https://discourse.slimframework.com/t/404-new-install/3356/4 "2019-08-16T10:53:52Z")

</div>

Which webserver are you using and how was it configured? Which skeleton are you using? The “official” Slim Skeleton doesn’t contain that route, so a 404 would be expected.

---

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 16, 2019, 11:27am UTC](https://discourse.slimframework.com/t/404-new-install/3356/5 "2019-08-16T11:27:58Z")

</div>

This is on a Linux Mint 19 machine.  
Apache2 PHP7+

I have previously got Slim 4 beta going a LM17 machine. I will check my Apache settings against that. Im assuming it is a host path error.

The slim skeleton aside, on a fresh LM19 lamp stack install, composer, slim4, psr7. Did not work for me either. Still a 404.

As far as the slim-skeleton, in the app/routes.php has this:

return function (App $app) {  
$container = $app-\>getContainer();

```
$app->group('/users', function (Group $group) use ($container) {
    $group->get('', ListUsersAction::class);
    $group->get('/{id}', ViewUserAction::class);
});

```

Looks like /users or /users/1 would work? Returns “Bill Gates” no?

---

<div class="post-metadata">

**Author:** ![kAlvaro](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/kalvaro/32/730_2.png) [@kAlvaro](https://discourse.slimframework.com/u/kAlvaro)\
**Post date:** [August 16, 2019, 2:56pm UTC](https://discourse.slimframework.com/t/404-new-install/3356/6 "2019-08-16T14:56:06Z")

</div>

> [@itgstl](#):
>
> my apache public html dir is located /var/www/html
> 
> slim is located in /var/www/html/newsite

If your routing script is located at `/var/www/html/newsite` then your Apache public HTML directory should be `/var/www/html/newsite/public` rather than `/var/www/html` (that’s what the name `public` is meant to imply) and the URL should be `http://localhost/users/1` rather than `http://localhost/newsite/public/users/1`.

If you want something different, you need to tweak your configuration quite a lot. Perhaps you can put your files in a completely different location and make `/var/www/html/newsite` a symlink to wherever `public` is, or you can create an Apache [Alias](http://httpd.apache.org/docs/current/mod/mod_alias.html#alias). In either case, I’m not sure whether Slim itself needs specific configuration.

---

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 17, 2019, 11:48am UTC](https://discourse.slimframework.com/t/404-new-install/3356/7 "2019-08-17T11:48:10Z")

</div>

I will work with adding a new vhost to Apache to see if that works. The odd thing is that from the machine that works, to the machine that does not, I do not see any difference in Apache config files.

---

<div class="post-metadata">

**Author:** ![aghezzi](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@aghezzi](https://discourse.slimframework.com/u/aghezzi)\
**Post date:** [August 20, 2019, 4:26am UTC](https://discourse.slimframework.com/t/404-new-install/3356/8 "2019-08-20T04:26:22Z")

</div>

I suggest a simple test to understand where the problem is  
in skeleton public dir run the following command from bash

php -S localhost:8080 -t .

than click the link you should see your home page or an error msg  
HTH

---

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 20, 2019, 11:36am UTC](https://discourse.slimframework.com/t/404-new-install/3356/9 "2019-08-20T11:36:48Z")

</div>

The problem I was having is solved here. Apache configuration. I did not have much luck with RewriteBase, but then again I did not give it much attention. I just changed the route parameter and it worked fine.

> [@Slim 4 - HttpNotFoundException](https://discourse.slimframework.com/t/slim-4-httpnotfoundexception/3273/13):
>
> same issue; read entire thread you are missing rewrite base in htaccess

---

<div class="post-metadata">

**Author:** ![mrsnax](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/mrsnax/32/769_2.png) [@mrsnax](https://discourse.slimframework.com/u/mrsnax)\
**Post date:** [August 21, 2019, 7:07am UTC](https://discourse.slimframework.com/t/404-new-install/3356/10 "2019-08-21T07:07:01Z")

</div>

May you share Apache config? I’ve same problem here when doing new install

---

<div class="post-metadata">

**Author:** ![itgstl](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@itgstl](https://discourse.slimframework.com/u/itgstl)\
**Post date:** [August 21, 2019, 11:05am UTC](https://discourse.slimframework.com/t/404-new-install/3356/11 "2019-08-21T11:05:33Z")

</div>

The Apache config located /etc/apache2 apache2.conf is only slightly changed. Your root public www directory changes from AllowOverride None to AllowOverride All

Directory /var/www/\>  
Options Indexes FollowSymLinks  
AllowOverride All  
Require all granted  
\</Directory

then you must go into the slim skeleton to /app/routes.php and change the path to reflect your directory structure.

$app-\>group(’/users’ … became $app-\>group(’/newsite/public/users’

…

```
$app->group('/newsite/public/users', function (Group $group) use ($container) {
    $group->get('', ListUsersAction::class);
    $group->get('/{id}', ViewUserAction::class);
})

```

[http://localhost/newsite/public/users](http://localhost/newsite/public/users) should display JSON result.

For production purposes you would need to configure Apache vhost. Having a long route path for every route is not preferable.

---

<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:** [August 21, 2019, 12:29pm UTC](https://discourse.slimframework.com/t/404-new-install/3356/12 "2019-08-21T12:29:35Z")

</div>

There is a library that helps to solve the basePath issue for Apache.

- [selective-php/basepath](https://github.com/selective-php/basepath)

Feedback is welcome 🙂

---

<div class="post-metadata">

**Author:** ![Metalpha](https://avatars.discourse-cdn.com/v4/letter/m/87869e/32.png) [@Metalpha](https://discourse.slimframework.com/u/Metalpha)\
**Post date:** [February 28, 2020, 9:42am UTC](https://discourse.slimframework.com/t/404-new-install/3356/13 "2020-02-28T09:42:35Z")

</div>

Hello,

You can use that $app-\>setBasePath(‘xxx’);
