0

App::missing is not available and I can't find app/Exceptions/Handler.php It doesn't appear in my app directory:

im
(source: gyazo.com)

Am I using an old version of laravel or a not-complete source? Because everything works fine, but I want unknown routes to be redirected to some other route, such as a 404 page or a redirect to a homepage.

Community
  • 1
  • 1
Artemkller545
  • 979
  • 3
  • 21
  • 55

1 Answers1

5

You could define a 'general' or 'capture all' route at the end of your routes.php that handle any requests that did not match any of your routes. Then display a view with a 'missing page' message.

Route::any('/', function()
{
    // your redirect code goes here
});
Yasen Zhelev
  • 4,045
  • 3
  • 31
  • 56
  • Down-voting. Not a good idea. A proper handler/view should be set up that’ll send the correct HTTP header (404). – Martin Bean Apr 27 '15 at 17:29
  • 1
    Yes, I absolutely agree. And this is what any developer should do in the 'your code here' place. I am leaving that to developer to decide what they need there. This is only a solution to capture and then handle request to routes that do not exist. – Yasen Zhelev Apr 27 '15 at 17:39
  • 2
    @MartinBean While I agree in principle, I would not downvote this because it is valid for some approaches, for example single page applications where you want to redirect to the home page without serving up a 404. – marked-down Jul 07 '16 at 11:37