Tobias Hagenbeek
Tobias Hagenbeek

Reputation: 1213

redirect when route doesn't exist laravel 4

I'm using laravel 4 and when i have my project in production mode, i get "Sorry, the page you are looking for could not be found." when i hit a non existing route...

When i grep my code it's found in two places:

./vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php:129:                $title = 'Sorry, the page you are looking for could not be found.';
./vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php:52:        $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent());

No i would like to specify a route to handle 404's, but can't seem to find how to do this...

And the can someone maybe explain why it's using symfony error handling and where setting for that can be found?

Upvotes: 2

Views: 8173

Answers (1)

The Alpha
The Alpha

Reputation: 146191

You may register an error handler that handles all "404 Not Found" errors in your application, allowing you to return custom 404 error pages:

App::missing(function($exception)
{
    // return Response::view('errors.missing', array(), 404);
    return Redirect::to('someurl');
});

Check documentation.

Also, Laravel uses some Symphony components to simplify the development process of some core functionality of it's framework, including routing, response and many more.

Upvotes: 9

Related Questions