Subfolers中的路由控制器

时间:2016-04-08 23:03:00

标签: php codeigniter

我在Codeigniter中使用控制器的文件夹结构。它们如下

  • Folder1中

  • --- Controller1

  • ---控制器2
  • FOLDER2

  • --- Controller3

  • --- Controller 4

在配置文件中,我有以下代码

$route['folder'] = 'folder1';

$route['folder1/controller1'] = 'folder1/controller1';
$route['folder1/controller1/(:any)'] = 'folder1/controller1/$1';

$route['folder1/controller2'] = 'folder1/controller2';
$route['folder1/controller2/(:any)'] = 'folder1/controller2/$1';



$route['folder'] = 'folder2';

$route['folder2/controller3'] = 'folder2/controller3';
$route['folder2/controller3/(:any)'] = 'folder2/controller3/$1';

$route['folder2/controller4'] = 'folder1/controller4';
$route['folder2/controller4/(:any)'] = 'folder1/controller4/$1';

$route['default_controller'] = 'folder1/controller1';

但是当我浏览我的浏览器时this (duplicate?) question它没有加载配置文件中设置的默认控制器。这是folder1 / controller1。 有人可以帮忙吗?

非常感谢。

由于

1 个答案:

答案 0 :(得分:0)

$route['folder'] = 'folder1';
$route['folder'] = 'folder2';

请删除其中一行。还要添加default_controller top of routes.php文件。