Reputation: 105
how can i redirect the page if action doesn't exist. right now cakephp shows a default View/errors/missing_action.ctp . Having Message:-
(Page Not Found! Looks like we could not find the Action (page) you were looking for. )
I want to redirect my page whenever page is not found. Can any one guide me how to achieve that?
Upvotes: 1
Views: 2190
Reputation: 941
The "Missing Action" error is only shown in development mode. On the live server you should always change the setting Configure::write('debug', 0);
in /app/Config/core.php
(= Production Mode). In Production Mode the 404 will be rendered. You can change/define the template in /app/View/Errors/
. To change the cake default error behavior, you can create your own error controller. Just copy the file lib/Cake/Controller/CakeErrorController.php
to app/Controller/CakeErrorController.php
and make your modifications or redirects in this file...
Upvotes: 1
Reputation: 13971
Create AppController::appError(); to redirect to required page
class AppError extends ErrorHandler {
function missingAction($parameters) {
$this->controller->redirect('/');
}
}
Upvotes: 0