I have two application in Codeigniter project. 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. I only can be calling Dashboard controller which is the default controller that I was set. 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With