This tutorial will show you an example on how to we can separate front-end and back-end in Codeigniter. Front-end which is mainly used by public users who navigate through the site and sometimes register themselves to get updates on the site activities, new posts, update on a particular post etc. Back-end which is mainly used by site author, administrator, editor etc. to manage the site. So back-end will be restricted to some people with given roles.

Here I can use different URL, i.e.,, for accessing directly admin login page or I can also use the URL where login link is present on front-end header to navigate to the admin section.

First you need to go through, and tutorials for getting an idea for better understanding of the following implementation.

Step 1. Create a config file app_config.php with the following source code and put it under <project root>/application/config/

Step 2. Verify <project root>/application/config/autoload.php with the following content

Step 3. Check default controller is home in <project root>/application/config/routes.php 

Step 4. We will use two different templates for front-end and back-end. So check <project root>/application/config/template.php 

Step 5. We need to create form validation library to make codeigniter validation work correctly. Create below file at <project root>/application/libraries/my_form_validation.php

Step 6. Create one userauth library related to user authentication functionalities at <project root>/application/libraries/userauth.php. Note that all hardcoded values used here for demo purpose only and those values should come from database or any other external system as per your need.

Step 7. Now we will create MY_Controller at <project root>/application/core/MY_Controller.php which will be extended by Public_Controller for front-end and Admin_Controller for back-end to meet extended functionality performed by those two different templates.

Step 8. Create Public_Controller at <project root>/application/core/Public_Controller.php for front-end related view.

Step 9. Create Public_Controller at <project root>/application/core/MY_Controller.php for back-end related view.

Step 10. For other files like public/admin templates, css, js, images, HMVC modules etc. please download from the below link and put them accordingly.


Step 11. Run the application.

That’s all. Thank you for your reading.

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

2 Thoughts on “Separating Front-end and Back-end in Codeigniter”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.