Skip to main content
PHP Blog

Back to all posts

How to Make Custom 404 "Not Found" Page In Codeigniter?

Published on
4 min read
How to Make Custom 404 "Not Found" Page In Codeigniter? image

Best Custom 404 Page Tools to Buy in November 2025

1 FOXWELL NT301 OBD2 Scanner Live Data Professional Mechanic OBDII Diagnostic Code Reader Tool for Check Engine Light

FOXWELL NT301 OBD2 Scanner Live Data Professional Mechanic OBDII Diagnostic Code Reader Tool for Check Engine Light

  • QUICK FAULT CODE READING: EASILY CHECK ENGINE LIGHTS & DTCS FAST!

  • LIVE DATA GRAPHING: MONITOR VEHICLE PERFORMANCE IN REAL-TIME!

  • USER-FRIENDLY DESIGN: PLUG & PLAY FUNCTIONALITY FOR EFFORTLESS USE!

BUY & SAVE
$69.99 $89.90
Save 22%
FOXWELL NT301 OBD2 Scanner Live Data Professional Mechanic OBDII Diagnostic Code Reader Tool for Check Engine Light
2 FOXWELL NT201 OBD2 Scanner Code Reader for Cars and Trucks - Reset Check Engine Light, Read and Clear Fault Codes, Live Data Diagnostic Tool for All Cars Since 1996

FOXWELL NT201 OBD2 Scanner Code Reader for Cars and Trucks - Reset Check Engine Light, Read and Clear Fault Codes, Live Data Diagnostic Tool for All Cars Since 1996

  • QUICKLY READ & CLEAR FAULT CODES: SAVE TIME AND COSTLY REPAIRS!

  • LIVE DATA ACCESS: IDENTIFY ISSUES WITH REAL-TIME ENGINE DIAGNOSTICS.

  • ONE-CLICK EMISSIONS TEST: EASY PRE-INSPECTION CHECKS WITH CLEAR INDICATORS.

BUY & SAVE
$34.96 $49.98
Save 30%
FOXWELL NT201 OBD2 Scanner Code Reader for Cars and Trucks - Reset Check Engine Light, Read and Clear Fault Codes, Live Data Diagnostic Tool for All Cars Since 1996
3 XTOOL D5 Car Code Reader and Reset Tool, Engine ABS SRS Transmission Car Diagnostic Tool with EPB Service, ABS Bleed, Throttle Relearn, Clear Check Engine Light Code Reader with 10 Resets, Free Update

XTOOL D5 Car Code Reader and Reset Tool, Engine ABS SRS Transmission Car Diagnostic Tool with EPB Service, ABS Bleed, Throttle Relearn, Clear Check Engine Light Code Reader with 10 Resets, Free Update

  • ALL-IN-ONE SCANNER: 10 RESET FUNCTIONS FOR EASY VEHICLE MAINTENANCE.

  • REAL-TIME DATA & DIAGNOSIS: INTUITIVE GRAPHS SIMPLIFY TROUBLESHOOTING.

  • LIFETIME UPDATES & WIDE COMPATIBILITY: NO EXTRA FEES FOR 90+ BRANDS!

BUY & SAVE
$159.00
XTOOL D5 Car Code Reader and Reset Tool, Engine ABS SRS Transmission Car Diagnostic Tool with EPB Service, ABS Bleed, Throttle Relearn, Clear Check Engine Light Code Reader with 10 Resets, Free Update
4 Docker para CodeIgniter 4 e PHP: Práticas Seguras, Documentação Automática e Casos de Uso (Portuguese Edition)

Docker para CodeIgniter 4 e PHP: Práticas Seguras, Documentação Automática e Casos de Uso (Portuguese Edition)

BUY & SAVE
$5.00
Docker para CodeIgniter 4 e PHP: Práticas Seguras, Documentação Automática e Casos de Uso (Portuguese Edition)
+
ONE MORE?

To create a custom 404 "not found" page in CodeIgniter, you can follow these steps:

Create a new view file called "404.php" in the "application/views/errors" folder of your CodeIgniter project.

Inside this view file, you can design the layout and add any content you want to display on the 404 page.

Open the "application/config/routes.php" file and add the following line to set the custom 404 page:

$route['404_override'] = 'errors/error_404';

Create a new controller file called "errors.php" in the "application/controllers" folder of your CodeIgniter project.

Inside this controller file, create a method called "error_404" which will load the custom 404 view file:

public function error_404() { $this->load->view('errors/404'); }

Now, when a page is not found on your website, CodeIgniter will automatically redirect the user to your custom 404 "not found" page.

What is the relationship between SEO and a custom 404 page in CodeIgniter?

SEO and a custom 404 page in CodeIgniter are related in the sense that having a well-designed and functional custom 404 page can help improve the overall SEO performance of a website.

When a user navigates to a broken or non-existent page on a website, they are typically presented with a standard 404 error page. However, creating a custom 404 page in CodeIgniter allows you to provide a more user-friendly and helpful experience for visitors who encounter a broken link or mistyped URL.

By customizing the content and design of your 404 page, you can keep users engaged, direct them to relevant content on your site, and encourage them to continue exploring. This can help reduce bounce rates and improve user experience, which are important factors that search engines like Google take into account when ranking websites.

Additionally, by including links and other relevant information on your custom 404 page, you can help search engine bots discover and index important pages on your site that may otherwise be overlooked if they are only accessible through broken links.

In summary, having a well-designed custom 404 page in CodeIgniter can improve user experience, reduce bounce rates, and ultimately contribute to better search engine rankings and overall SEO performance for your website.

What is the ideal content to include on a custom 404 page in CodeIgniter?

  1. A friendly and engaging message apologizing for the error and reassuring the user that the issue will be fixed.
  2. Suggestions or links to helpful resources such as the homepage, a search bar, or popular pages on the website.
  3. Contact information or a link to the support team for assistance.
  4. A search bar or navigation menu to help the user easily find what they were looking for.
  5. Links to related content or popular pages to help the user continue browsing the website.
  6. A humorous or creative image or illustration to make the error page more visually appealing and engaging.
  7. Custom branding or design elements to ensure the error page matches the overall look and feel of the website.

How to handle 404 errors in CodeIgniter?

In CodeIgniter, you can handle 404 errors by creating a custom 404 page and setting it up in the configuration file. Here's how you can do it:

  1. Create a custom 404 error page: Create a new PHP file in your views folder (e.g., application/views/errors/html/error_404.php) and add your custom message or content for the 404 error page.
  1. Update the configuration file: Open the application/config/config.php file and set the custom 404 page in the config array.

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-'; $config['error_view'] = 'errors/html/error_404.php';

  1. Handle 404 errors in the controller: You can also handle 404 errors in the controller by checking if a certain page or resource is not found and then showing the 404 error page.

public function show_page($page) { // Check if the page exists if (! file_exists(APPPATH.'views/pages/'.$page.'.php')) { // Show the custom 404 error page show_404(); }

// Load the requested page
$this->load->view('pages/'.$page);

}

By following these steps, you can handle 404 errors and show a custom 404 page in CodeIgniter when a page or resource is not found.