/** Redirect 404's to home
*****************************************/
App::missing(function($exception)
{
// return Response::view('errors.missing', array(), 404);
return Redirect::to('/');
});
I have this code in my routes.php file. I am wondering how to redirect back to the home page if there is a 404 error. Is this possible?
I just want to add a suggestion for cleaning it up a bit more. I'd like to credit the accepted answer for getting me started. In my opinion however since every action in this function will return something, the switch and else statement create a bit of bloat. So to clean it up just a tad, I'd do the following.
For that, you need to do add few lines of code to render method in app/Exceptions/Handler.php file which looks like this:
you may Just do this :
open : app\Exceptions\Handler.php
in handler.php you can replace this code :
by this :
return redirect('/');
it works very much for example :