In Laravel 5.4 and possibly some older ones, you can modify the app/exceptions/Handler.php and the render function as follows:
if( is_a( $exception, \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class ) ) { return redirect()->route( 'error_404' ); }
thus, every 404 errors are redirected to a specific real route, which acts like other site routes.
You can also send any data from the current request to show a reasonable error in the target.
Amib
source share