2017-07-30 14 views
5

私はCodeigniterプロジェクトで2つのアプリケーションを持っています。構造は次のとおりです。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、私は上のtu私に与えるリンクからの指示に従っていた。私はindex.phpを/ admin/index/phpにコピーしました – bagongpct

答えて

1

2つのアプリケーションディレクトリを用意するのではなく、管理領域をサブディレクトリに分割しないでください。など、あなたの公共コントローラおよび管理コントローラはモデルを共有することができますこの方法、ヘルパー、

だから、それは次のようになります。

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

の管理フォルダにリダイレクトする必要があります。 –

関連する問題