Codeigniter url management for two ends i.e End User & Admin

173 views Asked by At

Basically i wants to distinguish my URL for end user and admin.
As per CodeIgniter rule url works as

www.mysite.com/[controller]/[method]

1) Url management for End User
when a user see my page url should be same as codeigniter rule i.e

www.mysite.com/[controller]/[method]

2) Url management for Admin
But i wants to add a unique segment /control/ to serve for admin like

www.mysite.com/control/[controller]/[method]

basically here i just wants to add a segment to distinguish my admin access from end user


i am using some rewrite rules in .htaccess as

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

if it is possible please provide me a solution
Thank you very much

1

There are 1 answers

2
Mudshark On

If you only want the URL to look different, you can add this to your config/routes.php file:

$route['control/([a-z]+)'] = '$1/index'; //edited in for default index access
$route['control/([a-z]+)/([a-z]+)'] = '$1/$2'; // $1 = controller, $2 = method

Or you can add an actual folder "control" in your controllers folder, and put any admin-related controllers in there; i.e. have your URL structure reflect your controller folders structure.