Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6917995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:48:08+00:00 2026-05-27T09:48:08+00:00

I have been working with CodeIgniter for quite a while now and I’m currently

  • 0

I have been working with CodeIgniter for quite a while now and I’m currently doing a project for a client that would like a custom 404 page. Everything is fine and the 404_override it works great.

My issue comes when a visitor is trying to access a article that do not exist I would like to call the show_404() function, but this shows me the "out of box" 404 page and not the one written in the 404_override.

I have seen some fixes for older versions, but I can’t get it to work in 2.1. So if anyone can help me out of this I would be really grateful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:48:09+00:00Added an answer on May 27, 2026 at 9:48 am

    Redirect is cleanest; loading a view could work too.

    The problem here is that show_404() is usually called AFTER your controller has already loaded (something had to tell it show the 404 after all). CI doesn’t like loading a second controller at that point, which is the primary hurdle.

    Your best option probably is extending the show_404() function in the Exceptions class to redirect to your 404 route. Without a redirect, you’ll be stuck with showing a view or something that you know has all the “extra data” it needs prior to calling the 404 (or I guess you could load it in the Exceptions class too). It can get really complicated in some dynamic views.

    You obviously want something more advanced than just editing the 404 template in the errors folder. I’ve had problems trying to access get_instance() from that file, as sometimes it’s loaded before the controller is constructed. So, be careful if you try that 😉

    Update: Here’s a working example of extending the show_404() function to load a view

    <?php
    // application/core/MY_Exceptions.php
    class MY_Exceptions extends CI_Exceptions {
    
        public function show_404()
        {
            $CI =& get_instance();
            $CI->load->view('my_notfound_view');
            echo $CI->output->get_output();
            exit;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a web development library (for the CodeIgniter framework) that
I've been working on a home project using CodeIgniter Reactor, and have come to
I have been working on an application in Xcode for a while now and
I have been working with android for a little while now and feel pretty
I have been working on a web services related project for about the last
I have been working with a string[] array in C# that gets returned from
I have been working on some legacy C++ code that uses variable length structures
I have been working as a native C++ programmer for last few years. Now
I have been working with Struts for some time, but for a project I
I have been working on a wrapper for a COM object that can only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.