Laravel provides with default all errors page out of the box. So when you create your website, you want to change the view for error 404, server error page with your custom website page. You want to add suggestion or links in the 404 page.
In this tutorial, we will going to create custom 404 page. So lets get started.
First of create errors
directory in resources/views
. In this directory, create blade file 404.blade.php
and put your custom page HTML code here.
@extends('layouts.app')
@section('content')
<div class="container">
<div class="col-12">
<h1 class="heading">Page not found</h1>
<img src="{{ assets('404.png') }}" class="img-responsive">
<p class="lead">Oops! You broke the Internet.</p>
<p>It looks like you are lost. But don't worry, you can always navigate to <a href="{{ url('/') }}">Homepage</a> or return back.
</p>
</div>
</div>
@endsection
Now go through any non route path to open 404 page. You can see the current page is displaying in 404 page.
Laravel logic for error pages is, if you have any blade views inside resources/views/errors
directory, than it returns else Laravel default view loads. So if you want to change default server error(500) page, create blade file, resources/views/errors/500.blade.php
and in your .env
file set APP_DEBUG=false
.
It will return that view whenever server error occurs.
I hope you liked this tutorial and helped it. Thank you for giving time in reading article.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to show and hide div elements based on dropdown selection in jQuery
Use the jQuery change() method The fo...Laravel 7 - Dynamically Add Input Fields using HandlebarsJs
Hello Artisan In this tutorial i will...Create Dynamic SEO metatags in Laravel 8
There are many ways you can increase tra...Create REST API using Django Rest Framework
There are multiple ways to indite an API...React use one Component to many HTML Fragments
A react component is used to return mult...