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开发者_如何学JAVA.
Any ideas?
Thanks!
@jonjdavidjohn's suggestion should work, but there is another option if you don't go that way.
In config/routes.php re-route all /admin/requests to the appropriate controller:
// if you use this structure: controllers/pages.php
$route[admin/(:any)] = '$1';
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]
精彩评论