How to routes Controller sub folder using codeigniter?

你说的曾经没有我的故事 提交于 2019-12-24 00:51:03

问题


I have created controller file in sub folder of controller.

i have two type of sub folder for backend(admin) and frontend(user).

Structure of Controller

Controller
--backend
   ---admin.php
   ---dashboard.php
--frontend
   ---user.php

I want url for admin panel:

http://localhost/DemoSite/admin_panel/admin/dashboard

admin_panel want it in URL before every backend controller call

admin is Controller
dashboard is Function

For frontend :

http://localhost/DemoSite/user

I have done route like this :

$route['default_controller'] = 'frontend/user';
$route['admin/(:any)'] = "backend/$1";
$route['(:any)'] = "user/$1";

回答1:


Try to delete the last line in routes and create multiple routes to user:

//user routes
$route['default_controller'] = 'frontend/user';
$route['user'] = "frontend/user";

//admin routes
$route['admin/(:any)'] = "backend/$1";


来源:https://stackoverflow.com/questions/35627730/how-to-routes-controller-sub-folder-using-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!