Redirect to new page when error 404 occurs using Laravel 5.6

2

What is the correct way for Laravel 5.6 to redirect another route if it is 404 error?

I created the resources / views / errors / folder and the 404.blade.php and it worked fine, but I do not want to display the error, I want it to be redirected to another page.

    
asked by anonymous 10.05.2018 / 19:38

1 answer

2

You can create a script inside the page 404.blade.php to do this redirection, like this:

<script>
window.location = "http://www.yoururl.com";
</script>

Or change the file app/Exceptions/Handler.php of Laravel , to the line where it contains the following code snippet:

return response()->view('core.layout::error', ['code' => 404, ...

Where you can put the route you want instead of 'core.layout :: error'.

    
10.05.2018 / 20:00