Keiichi Wada
Keiichi Wada

Reputation: 55

Redirect to error page if destination doesn't exist

I'd like to let the users access to non-existent or error pages to redirect somewhere. If a user accesses *application.com/somewhere* and it doesn't exist, the user should be redirected to *application.com/dashboard*.

Do I have to make changes to config files or route.php?

Upvotes: 0

Views: 460

Answers (2)

giannis christofakis
giannis christofakis

Reputation: 8321

I think you can easily handle this

App::missing(function($exception)
{
    return Redirect::to('/dashboard');
});

http://laravel.com/docs/errors

Upvotes: 1

Keiichi Wada
Keiichi Wada

Reputation: 55

I solved it myself. puts below code on route.php. that'll be redirect to URL/dashboard when any error happens.

all of error redirect to URL/dashboard

App::error(function(Exception $exception, $code)
{
   Log::error($exception);

  if (Config::get('app.debug') == false) 
  {
    return Redirect::to('/dashboard');
  }
});

Upvotes: 1

Related Questions