Reputation: 37
Hello I am new in cakephp and I want to show an error page if someone enter wrong url in my cakephp application.
I am using this code as per given example on internet
CakePHP 2.0 - How to make custom error pages?
I am unable to see any custom error page in my application.I have used all the given steps added in that url
Upvotes: 0
Views: 479
Reputation:
The best way is handle all errors in AppController.php
public function beforeRender() {
parent::beforeRender();
if ($this->name == 'CakeError') {
$this->redirect(array(
'controller' => 'ExampleController', 'error_action'));
}
}
And make view View/ExampleController/error_action.ctp with your needs.
Upvotes: 0
Reputation: 1378
Try the second answer:
To customize the content of a 404-error page and don't need custom logic, simply edit the contents of app/View/Errors/error400.ctp.
Note that you need to also set your debug level to zero to see your custom error page.
Upvotes: 1