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 8545197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:44:20+00:00 2026-06-11T12:44:20+00:00

I am using CodeIgniter framework. I have files in my controllers folder like this:

  • 0

I am using CodeIgniter framework. I have files in my controllers folder like this:

 - Controllers
 --- admin.php - Admin Controller
 --- /Admin - Admin Folder
 ----- category.php - Category Controller in Admin folder.

The Url: mysite.com/index.php/admin/category says that page not found because it is trying to call the category function of admin controller but I want it to call the index function of category controller in Admin folder.

Also I am using the admin controller for create, edit etc. functions of admin controller like mysite.com/index.php/admin/create.

I think, I should use the $route array in config file. What routing should I use?

  • 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-06-11T12:44:21+00:00Added an answer on June 11, 2026 at 12:44 pm

    This is the default behavior of the CI core. See function _validate_request($segments) in system/core/Router.php. This function attempts to determine the path to the controller. It goes through different conditions one by one and returns the result once a given condition is met. Besides the other, there are two conditions involved:

    1. Is it a file? (system/core/Router.php line 271, CI 2.1.2)

      // Does the requested controller exist in the root folder?
      if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
      {
          return $segments;
      }
      
    2. Is it a folder? (system/core/Router.php line 277, CI 2.1.2)

      // Is the controller in a sub-folder?
      if (is_dir(APPPATH.'controllers/'.$segments[0]))
      {
          // ...
      

    In your case the function will return once the first of the two conditions is met, i.e. when admin.php file is found.

    There are two solutions:

    1. Rename the file or the folder and refactor the application respectively.
    2. Change the default behavior by extending the core. Basically that would conclude in changing the sequence of conditions checking. This can be accomplished by creating MY_Router class:

      class MY_Router extends CI_Router
      {
          // ...
      }
      

      and rewriting the original _validate_request() function with changed sequence of conditions. So first checking for directory and then for function.

    I would suggest the first solution, if it does not require too much refactoring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code here in PHP using Codeigniter framework, I can't seem to
I'm using CodeIgniter (a PHP framework) to build an app, and I have an
I am using codeigniter framework. where should i sanitize PHP input - controller or
I am using the CodeIgniter 2.1 PHP framework. I have a library file that
I have a web site done using codeigniter php framework and mysql, i have
I'm using Codeigniter a PHP framework and apache2. I have enabled Gzip and deflate
I'm using the Codeigniter PHP framework. In one of the config files, you can
I have a PHP application developed using the Codeigniter framework. My application works perfectly
Hi I am using CodeIgniter 1.7.3 framework in my project. I have given URL
I have been working an application using PHP & MySql on Codeigniter framework. It

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.