laravelhttp-redirecthttp-status-code-404http-status-code-301laravel-5

Laravel 5.2 How To redirect All 404 Errors to Homepage


How can I redirect all 404 errors to homepage? I have custom Error Page but google analytics is throwing too much errors.


Solution

  • Please consider the answer given in the documentation: https://laravel.com/docs/10.x/routing#fallback-routes

    For instance, in your web file:

    Route::fallback(function () {
        return redirect()->route('index');
    });