Search code examples
phpcodeignitercodeigniter-routing

Codeigniter - uri routing, skipping a segment


I'd like to skip a section of a uri with Code Igniter. I have the following urls

/about
/info
/admin/users
/admin/pages
/admin/pages/edit/123

However I'd like to skip admin when searching for the class, i.e. the default config acts like this:

/admin[class]/pages[function]/edit[var]/123[var]

However I'd like it to work like this:

/admin[skip]/pages[class]/edit[function]/123[var]

Unfortunately I can't just start my application one level deeper as I have top level pages too.

I'd rather not add a rule for every page if I don't have to.

Any ideas?

Thanks!


Solution

  • You can organize your controllers into subdirectories a single level deep in codeigniter out of the box.

    so your directory structure would be

    /application
        /controllers
            /admin
                pages.php [pages class]