I am using Laravel version 5.2 and don't know how to redirect Laravel default page to my template 404 page
use abort(404);
Some exceptions describe HTTP error codes from the server. For example, this may be a "page not found" error (404), an "unauthorized error" (401) or even a developer generated 500 error. In order to generate such a response from anywhere in your application, use the following:
abort(404);
If you invoke abort(404);
anywhere in your route or controller it will throw HTTPNotFoundException
which looks for a blade template to display in resources/views/errors/
directory with the filename same as the error code.
Example:
in your app/Http/routes.php
Route::get('/test', function(){
return abort(404);
});
in your resources/views/errors/
directory create 404.blade.php, notice the name of the file corresponds with the abort(404);
Reference: https://laravel.com/docs/5.2/errors#http-exceptions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With