Learn Pain Less

HomeOur TeamContact
Codeigniter 4
How to create custom 404 page in Codeigniter 4
Pawneshwer Gupta
Pawneshwer Gupta
June 13, 2020
1 min

Table Of Contents

01
custom 404 page in Codeigniter 4
02
Why 404 error not found
How to create custom 404 page in Codeigniter 4

custom 404 page in Codeigniter 4

In this tutorial, I will show you how you can create a fully customized 404 error page in Codeignitor 4 (how to create a custom 404 error page in CodeIgniter 4). I will start by creating a controller and then proceed to set up routes.

Why 404 error not found

404 not found is HTML error code indicating a special condition in which the connection between the server and the client is working correctly, but the server could not find the resource requested by the client.

The underlying causes of the error are many, but the normal process is the same in all cases. The server has received a request for a resource that does not exist on the server hosting PHP. A very common cause of this condition is broken links that point to pages or resources that have been removed (or taken down) by the website administrator. CodeIgniter 4 displays a simple 404 error page whenever a user navigates to a broken link.

So lets start coding

create 404.php file inside Views directory of your Codeigniter 4 project. And paste below code.

create or modify style.css inside ”public/css” directory in Codeigniter 4 project, and paste below code:

Download this background image and paste into ”public/img” directory in your codeigniter 4 project.

modify your Routes.php file inside ”app/config” directory of your codeigniter 4 project. And copy code from below code starting from line number 22 to 24.

That’s it, Now your custom 404 not found page is ready. You will get output like below screenshot.

custom 404 page in Codeigniter 4
custom 404 page in Codeigniter 4

custom 404 page in Codeigniter 4

You can easily customize it and make it more user friendly for the user.

You can also watch my video on Youtube about custom 404 page in Codeigniter 4

The conclusion

In this small article, I have demonstrated a custom designed 404 error page for your Codeigniter 4 project. A custom 404 error page is an ideal way to retain visitors to the website and redirect them to the appropriate pages on the website. This greatly reduces the bounce rate of websites and ensures that visitors are interested in your website. If you have further questions and questions about creating custom 404 pages for Codeigniter 4 projects, post them in the comments below.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

PHPcustom 404error pagefeatured

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

How Throttler and Rate limiting work in codeigniter 4
How Throttler and Rate limiting work in codeigniter 4
July 18, 2020
1 min
How to test Socket io with Postman
Postman
How to test Socket io with Postman
July 30, 2021
2 min
Why we have to think about state in flutter (Beginner's question)
Flutter
Why we have to think about state in flutter (Beginner's question)
August 08, 2020
2 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media