2017-07-30 279 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

我喜歡這種方法。 –