CakePHP : Redirect a 404 Error Page

Tuesday, October 25, 2011 2 Comments

Just curious if maybe sometimes I need it or something :D
class AppError extends ErrorHandler {
     function error404($params) {
         // redirect to homepage
         $this->controller->redirect('/');
     }
}
Just simply put it inside app/app_error.php And taraaa.. It works on me.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Do you think I forgot to change this text? No, dude. I did it on purpose ahahahay..

2 comments

Write comments
Anonymous
AUTHOR
November 28, 2012 at 8:02 PM delete

hi,

if i set debug mode to 0 then it's not working ...

how to do this ?

Thanks..

Reply
avatar
tom
AUTHOR
November 29, 2012 at 5:30 AM delete

To @anonymous, hm? It should be fine and working. Just FYI, it's for cakePHP 1.3.x, since my apps mostly on that version. I still not develop any app with higher version.

What is 'not working here'? Is it not redirecting? Or what?

Reply
avatar