Codeigniter:创建索引页面

My folder structure is as following

admin
__master
_______address_book
_______Users
_______Product
_______etc
__operations
_______register_orders
_______payments
_______etc

I have created controllers for address_book,users,products,register_orders, payments etc to reduce the complexity of each controller.

Now, how to handle index page request for www.abc.com/admin ? I have created Admin controller in /controllers directory then other links like www.abc.com/admin/master/address_book will not work.

How to handle both requests? I would also like to know is there any way to handle each index page requests eg:

www.abc.com/admin/
www.abc.com/admin/master/
www.abc.com/admin/operations/

To access each request with url like-

www.abc.com/admin/
www.abc.com/admin/master/
www.abc.com/admin/operations/

you have to use codeigniter's routing. And for routing there are a config file under aplication/config folder named routes.php. Add all your routes in this file. Suppose you want to access this url-

www.abc.com/admin/operations/

then you have to create a new route for this in the route file, like-

$route['admin/operations']  = 'admin/operations';

where in $route array index you have to mention what will be the url and the value against this index you have to mention the controller's path and also you can mention the controller's function name which will be invoked (for index function there no need for mentioning).

By default Codeigniter does not support multi level folder controllers in the controller directory, you can try to extends the base behaviour adding this functionality https://github.com/ollierattue/codeigniter-multi-level-controller-extension/blob/master/core/MY_Router.php

Or in the alternative way, you can put all your classes in your base application/controller folder and use the Codeigniter routing system

By Codeigniter v3.0 was highly improved routing system, you needn't relying on the classical controllers/methods routing system anymore.

You can specify your routing URI - Method directly

$route['admin'] = 'admin/index'
$route['admin/master'] = 'master/index'
$route['admin/operations'] = 'operations/index'

View more at CodeIgniter 3.0 Docs - URI Routing