[英]Can't calling controller in codeigniter
I have two application in Codeigniter project. 我在Codeigniter项目中有两个应用程序。 bellow is the structure:
下面是结构:
/admin
/index.php
/application
/admin
/controllers
/Dashboard
/Product
/Post
/public
/controllers
/Home
/About
/Contact
/system
/index.php
The public application can work normally. 公共应用程序可以正常工作。 and I can call all of controllers with this setting:
我可以使用此设置调用所有控制器:
/*----seting in /index.php---*/
$application_folder = 'application/public';
/*----seting in /application/public/config/config.php---*/
$config['base_url'] = 'http://localhost/myweb/';
/*----seting in /application/admin/config/routes.php---*/
$route['default_controller'] = 'Home';
but, The Admin application can't work normally. 但是,Admin应用程序无法正常工作。 I only can be calling Dashboard controller which is the default controller that I was set.
我只能调用Dashboard控制器,这是我设置的默认控制器。 the setting look like this:
设置看起来像这样:
/*----setting in /admin/index.php---*/
$application_folder = '../application/admin';
/*----seting in /application/admin/config/config.php---*/
$config['base_url'] = 'http://localhost/myweb/admin/';
/*----seting in /application/admin/config/routes.php---*/
$route['default_controller'] = 'Dashboard';
so, when I visit: 所以,当我访问时:
http://localhost/myweb/ //it will return home page
http://localhost/myweb/admin //it will return dashboard page
http://localhost/myweb/admin/product //it will return error
can anyone help me to fix this case? 任何人都可以帮我解决这个案子吗?
Why not seperate your admin area into a sub-directory, rather than having two application directories. 为什么不将管理区域分成子目录,而不是有两个应用程序目录。 That way your public controllers and admin controllers can share models, helpers, etc
这样你的公共控制器和管理员控制器就可以共享模型,助手等
So it would be: 所以它会是:
/application
/controllers
/admin
Index.php <-- admin controller inside 'admin' directory
Index.php <-- public controller outside 'admin' directory
/models
/views
/admin
/public
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.