简体   繁体   中英

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?

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');
  }
});

I think you can easily handle this

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

http://laravel.com/docs/errors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM