# AppController is not working on sub directory

**URL:** <https://discourse.cakephp.org/t/appcontroller-is-not-working-on-sub-directory/6555>\
**Category:** Uncategorized\
**Created:** [August 29, 2019, 8:58am UTC](https://discourse.cakephp.org/t/appcontroller-is-not-working-on-sub-directory/6555 "2019-08-29T08:58:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aneh](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/aneh/32/408_2.png) [@aneh](https://discourse.cakephp.org/u/aneh)\
**Post date:** [August 29, 2019, 8:58am UTC](https://discourse.cakephp.org/t/appcontroller-is-not-working-on-sub-directory/6555/1 "2019-08-29T08:58:50Z")

</div>

Hi, I am creating a REST Api But App Controller is not called.

![Screenshot%20at%20Aug%2029%2014-26-08](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/5/544ab6c3fc54aa9d876c1d4fd5c1cd1c3200fae9.png)

Route File:-

```
Router::prefix('ca/api', function ($routes) {
    $routes->setExtensions(['json']);
    $routes->connect('/login', ['controller' => 'Login', 'action' => 'login', "prefix" => "ca/api"]);
    $routes->connect('/dashboard', ['controller' => 'Dashboard', 'action' => 'home', 'prefix' => "ca/api"]);

    $routes->fallbacks('InflectedRoute');
});

```

AppController  
\<?php  
namespace App\Controller\Ca\Api;

```
use Cake\Controller\Controller;
use Cake\Event\Event;

class AppController extends Controller
{
    public function initialize()
    {
        parent::initialize();

        $this->loadComponent('RequestHandler');
        $this->loadComponent('Auth', [
            'storage' => 'Memory',
            'authenticate' => [
                'ADmad/JwtAuth.Jwt' => [
                    'parameter' => 'token',
                    'userModel' => 'Users',
                    'fields' => [
                        'username' => 'id'
                    ],
                    'queryDatasource' => true
                ]
            ],
            'unauthorizedRedirect' => false,
            'checkAuthIn' => 'Controller.initialize'
        ]);
    }
}

```

I don’t understand why it did not work. Thanks for any help.

---

<div class="post-metadata">

**Author:** ![kailashdesk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kailashdesk/32/1493_2.png) [@kailashdesk](https://discourse.cakephp.org/u/kailashdesk)\
**Post date:** [August 29, 2019, 9:51am UTC](https://discourse.cakephp.org/t/appcontroller-is-not-working-on-sub-directory/6555/2 "2019-08-29T09:51:42Z")

</div>

I think this link will be helpful for you:

> <https://stackoverflow.com/questions/8836128/cakephp-organise-controllers-in-subfolders>
