Reaching page not found in controller


#1

I am using cake 2.3.4, and I am new to cake and mvc in general.

I am trying to add a new static page with the following url: /giftcard.

And so I added a controller called GiftCard, and added the view action, which accepts no parameters, and should display only a page with an iframe.

The problem is that I get a page not found on the server error, when I navigate to the url:

I think the route is configured ok, and I am importing the AppController inside the controller, still the Controller is class is not executed. I tried adding a die() statement to the start of the controller, but it does not even call that.

the route:

Router::connect('/גיפט-קארד/', array('lang' => 'heb','controller' => 'giftcards', 'action' => 'view'));
Router::connect('/giftcard/', array('controller' => 'giftcards', 'action' => 'view'));

the giftcard controller:

<?php
App::uses('AppController', 'Controller');
class GiftCardsController extends AppController {
    public function index() {
        $this->Item->recursive = 0;
        $this->set('giftcards', $this->Paginator->paginate());
    }

    public function view($id = null) {
        $this->Render();
    }
}

Please help. Thanks in advance!


#2

I believe that when you use CamelCase controller names, you need to use under_score names in your routes. In your case, you’d want to either change the controller to Giftcards, or change the controller specified in your route to gift_cards.