# New Controller 404 Error

**URL:** <https://discourse.cakephp.org/t/new-controller-404-error/9042>\
**Category:** Need Help\
**Created:** [February 23, 2021, 2:48pm UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042 "2021-02-23T14:48:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aldohr](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Aldohr](https://discourse.cakephp.org/u/Aldohr)\
**Post date:** [February 23, 2021, 2:48pm UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042/1 "2021-02-23T14:48:00Z")

</div>

I apologize if this question seems basic, but I’ve been reading the Cookbook and struggling for hours and don’t understand why I can’t get a new controller to work. My understanding is that Controllers work similar to python flask routes, but maybe I’m mistaken. I just want to create a page and start building/learning off of that but no matter what I do, I just get error 404 when I try to load /test.

I have created a new project:  
`php composer.phar create-project --prefer-dist cakephp/app:4.* myapp`

I created a file: src/Controller/TestController.php

and added the following code:

```
<?php
namespace App\Controller;

class TestController extends AppController
{
    public function index()
    {
    }
}
```

---

<div class="post-metadata">

**Author:** ![FinlayDaG33k](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/finlaydag33k/32/1049_2.png) [@FinlayDaG33k](https://discourse.cakephp.org/u/FinlayDaG33k)\
**Post date:** [February 23, 2021, 8:47pm UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042/2 "2021-02-23T20:47:54Z")

</div>

What kind of 404 do you get?  
like, your webserver’s 404 or CakePHP’s big bad red telling you it’s missing the controller?

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [February 23, 2021, 10:23pm UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042/3 "2021-02-23T22:23:16Z")

</div>

It’s been a while since I used `create-project`. Does that automatically do `composer install` for you, to get all the dependencies and autoloader installed in the `vendor` folder? If not, did you do that part?

---

<div class="post-metadata">

**Author:** ![Aldohr](https://avatars.discourse-cdn.com/v4/letter/a/96bed5/32.png) [@Aldohr](https://discourse.cakephp.org/u/Aldohr)\
**Post date:** [March 2, 2021, 10:58pm UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042/4 "2021-03-02T22:58:16Z")

</div>

@FinlayDaG33k got me thinking in the right direction. I was receiving the error from the webserver. For some reason, although I had already set “AllowOverride All” I had to do this:

sudo mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

Thanks for asking the right questions!

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [March 3, 2021, 12:51am UTC](https://discourse.cakephp.org/t/new-controller-404-error/9042/5 "2021-03-03T00:51:54Z")

</div>

I believe you’re supposed to link files from `mods-available` into `mods-enabled`, not move them. A subsequent update to Apache might update the file for loading that module; a symlink would pick that change up, but a moved file won’t.
