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

  • Home
  • SEARCH
  • 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 7916333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:46:00+00:00 2026-06-03T14:46:00+00:00

I have my controllers organized in subfolders, like this: folder1/controller1 folder1/controller2 folder2/controller1 folder2/controller2 I

  • 0

I have my controllers organized in subfolders, like this:

folder1/controller1
folder1/controller2
folder2/controller1
folder2/controller2

I need to get both the controller and the subfolder name, but right now I can only get the controller name using

$CI =& get_instance();
$CI->router->class;

I also tried this one:

$CI->uri->uri_string()

But if I call my controller with a method, it will return it too, like this

full url:

http://localhost/codeigniter/folder1/controller1/index

will return

folder1/controller1/index

instead of

folder1/controller1

I can do this by using the class name to remove the methods and arguments, but I want to know if there is a better solution.

Thanks in advance!

  • 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-03T14:46:03+00:00Added an answer on June 3, 2026 at 2:46 pm
    print_r($this->router);
    

    Here you have all the other goodies!

    In you case you want $this->router->directory

    It returns folders/to/controller/ with a trailing /.

    Example:
    Adress: http://www.example.com/folder1/controller1

    echo $this->router;

    Outputs:
    folder1/

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

Sidebar

Related Questions

I Have an MVC Project roughly organized like this: Project 1: MVC app (ViewModels,
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
I have two view controllers in a tabbar which can both edit data. Therefore,
I have Controller: [MySite]\Controllers\DistributionTools\TrackingChannelsController.cs [HttpPost] public void InitTcFirstPageView() { var model = new TcFirstPageModel
I'm using Rails 3 and I'd like to move some controller files from app/controllers
I have my app like this : a navigationBar in the app delegate with
I have the project organized in this way: User is the main resource, each
I have many routes like: //routes app.get(page1/:action, function(req, res) { ... } app.get(page2/:action, function(req,
i have several controllers which will all be using common functionality. So i have
I have many controllers that will have some similar behavior, e.g. the user should

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.