2017-07-30 280 views
5

我在Codeigniter项目中有两个应用程序。波纹管的结构如下:Can not calling in 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应用程序无法正常工作。我只能调用仪表板控制器,这是我设置的默认控制器。该设置是这样的:

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

谁能帮助我解决这个问题呢?

+0

可能是此链接应帮助[链接](https://philsturgeon.uk/codeigniter/ 2009/07/08/Create-an-Admin-panel-with-CodeIgniter /) –

+0

你有拷贝索引吗? @bagongpct –

+0

嗨ankit,我遵循你给我上面的链接的指令。我被复制index.php到/ admin/index/php – bagongpct

回答

1

为什么不把你的管理区域分成子目录,而不是有两个应用程序目录。这样,你的公共控制器和管理控制器能够共享模型,佣工等

因此,这将是:

/application 
    /controllers 
     /admin 
      Index.php <-- admin controller inside 'admin' directory 
     Index.php <-- public controller outside 'admin' directory 
    /models 
    /views 
     /admin 
     /public 
+0

我喜欢这种方法。 –