使用CodeIgniter的前端网站和管理面板

I am working codeigniter, Here I have website which contains frontend website and admin panel. Now I need to add admin panel in codeigniter. I need to get URLs as following:

This is for frontend http://example.com/frontend

This is for admin panel http://example.com/frontend/adminpanel

Can anyone help me how can I do this in codeigniter.

I tried creating a directory in the applications/controllers/adminpanel but it not working showing me 404 error.

you can create a controller like below..

class frontend extends CI_Controller {
    public function index(){
        // Front View HERE
    }
    public function adminpanel(){
       // Admin Pannel View HERE
    }
}

OR

Write a rule in Routes.php

$route['frontend/adminpanel'] = 'controlerName/FunctionName';
// here Controller And Function Name denotes the controller you created for admin Panel 

In Codeigniter you shouldn't create directories to achieve this form of URLs.

To get the URL as you mentioned, you have to create a controller named frontend and inside the controller create a function called adminpanel, only then, you can access the output of the function with this URL

http://example.com/frontend/adminpanel

TIP

The most practical way to make the admin panel is to create another controller for the adminpanel. In this way, it will be easier for you to create functions in the adminpanel and get URLs like the following:

http://example.com/adminpanel/add_user/