是否可以在 Codeigniter 中同时使用基于query_string和分段的 url 路由


Is it possible to use both query_string and segment based url routing in Codeigniter?

我已经创建了一个应用程序,并在控制器中创建了两个文件夹。

1)frontend (User Panel)
2)backend (Admin Panel)

控制器结构:

--application
  --controller
    --frontend
       --product.php
       --customer.php
    --backend
      --admin.php
      --order.php

我正在使用配置设置:

$config['uri_protocol'] = 'QUERY_STRING';
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = TRUE;

我正在为后端(管理面板)使用此 URL 格式,

http://localhost/DemoApp/index.php?c=admin_controller&m=customer_order&d=backend

但是对于前端(用户面板),我想使用基于分段的URL:

http://localhost/DemoApp/user_controller/customer

是否可以使用 ? 和任何其他选择来执行这两种类型的 URL 模式。

这在技术上是可行的,但框架的设计不允许这样做。或者换句话说 - 它并不像找出正确的配置值那么简单。

相反,您需要找出一种基于 URI 使用不同配置的方法,并且必须在框架本身初始化之前执行该逻辑(即在运行时更改配置将不起作用)。

您可以从索引.php文件内部执行此操作。