我在控制器中创建了一个子文件夹
Controller文件夹的结构:
--controller
--backend
--dashboard.php
--products.php
--frontend
--index.php
--users.php
我在route.php文件中创建了一些规则
$route['default_controller'] = 'backend/admin_controller/';
$route['admin_panel'] = "backend/admin_controller/dashboard";
$route['admin_panel/login'] = "backend/admin_controller/index";
$route['admin_panel/(:any)'] = "backend/admin_controller/$1";
当我打开任何链接时,这非常有效:
http://localhost/Demo_app/admin_panel/products
http://localhost/Demo_app/admin_panel/dashboard
这些工作正常,但是当我传递参数来更新产品时,它会找到错误的网址。
对于这些链接(点击这些链接时)
http://localhost/Demo_app/admin_panel/add_product/69
http://localhost/Demo_app/admin_panel/add_product/0/69
/* 69 is product id and 0 is status of product to active or unactive
我很困惑为此创建规则。
答案 0 :(得分:1)
尝试使用此特定路线
$route['admin_panel/add_product/(:any)/(:any)'] = "backend/admin_controller/your_function/$1/$2";