简体   繁体   中英

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

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 ie

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

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; ie have your URL structure reflect your controller folders structure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM