alex
alex

Reputation: 37

Cakephp error custom page

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

Answers (2)

user3318206
user3318206

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

Ben Hitchcock
Ben Hitchcock

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

Related Questions