子文件夹中的codeigniter控制器

I'm designing a system where the uri's look as following

my-app.com/client-name/admin/foo
my-app.com/client-name/admin/bar

Where client-name is variable. Obviously I want to put the admin controllers in a sub-folder to maintain my sanity. So my folders can look as following...

/application/controllers/admin/foo.php
/application/controllers/admin/bar.php

Problem:

From the docs: "Organizing Your Controllers into Sub-folders When using this feature the first segment of your URI must specify the folder."

Is there anyway to get around this?

Could I create an admin controller

/application/controllers/admin.php

And use the _remap function to manually load controllers from the subfolder?

update:

My routes look like this

// Admin Root
$route['(:any)/admin'] = "admin/welcome";

Then before any controllers load I validate the first URI segment to make sure that client exists.

All clients use the same controllers and routes.

You can attempt to extend your routing method. like:

<?php

/*
 * Custom router function v 0.1
 *
 * Add functionality : read into more than one sub-folder
 *
 */

Class MY_Router extends CI_Router
{
    Function MY_Router()
    {
        parent::CI_Router();
    }

    function _validate_request($segments)
    {
        if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))
        {
            return $segments;
        }

        if (is_dir(APPPATH.'controllers/'.$segments[0]))
        {
            $this->set_directory($segments[0]);
            $segments = array_slice($segments, 1);

            /* ----------- ADDED CODE ------------ */

            while(count($segments) > 0 && is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]))
            {
                // Set the directory and remove it from the segment array
            $this->set_directory($this->directory . $segments[0]);
            $segments = array_slice($segments, 1);
            }

            /* ----------- END ------------ */

            if (count($segments) > 0)
            {
                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))
                {
                    show_404($this->fetch_directory().$segments[0]);
                }
            }
            else
            {
                $this->set_class($this->default_controller);
                $this->set_method('index');

                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))
                {
                    $this->directory = '';
                    return array();
                }

            }

            return $segments;
        }

        show_404($segments[0]);
    }
}

?>

All though this method may not work for everyone, and may cause more problems then its worth in the long run, but if you wanted to seperat you're controllers for whatever reason, it is possible. But will take some fair amount of tweaking to get to work. Note: its likely you will want to do this with a fresh install and know for sure that this is how you want to handle things.

I take no credit for the above code, the original reference can be found here. http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/

Turns out this just works if you setup your routes manually.

Awesome!