繁体   English   中英

无法在codeigniter中调用控制器

[英]Can't calling controller in codeigniter

我在Codeigniter项目中有两个应用程序。 下面是结构:

/admin
    /index.php
/application
    /admin
        /controllers
           /Dashboard
           /Product
           /Post
    /public
        /controllers
           /Home
           /About
           /Contact
/system
/index.php

公共应用程序可以正常工作。 我可以使用此设置调用所有控制器:

/*----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';

但是,Admin应用程序无法正常工作。 我只能调用Dashboard控制器,这是我设置的默认控制器。 设置看起来像这样:

/*----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';

所以,当我访问时:

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

任何人都可以帮我解决这个案子吗?

为什么不将管理区域分成子目录,而不是有两个应用程序目录。 这样你的公共控制器和管理员控制器就可以共享模型,助手等

所以它会是:

/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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM