【发布时间】:2010-08-02 07:40:37
【问题描述】:
我已经在配置文件中进行了两项更改,以启用 $_GET 数组
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = true;
但每当我尝试将我的代码运行为http://example.com/controller/function/$demo=demo
它重定向到默认控制器
【问题讨论】:
我已经在配置文件中进行了两项更改,以启用 $_GET 数组
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = true;
但每当我尝试将我的代码运行为http://example.com/controller/function/$demo=demo
它重定向到默认控制器
【问题讨论】:
在 CodeIgniter 中启用查询字符串意味着您正在使用查询字符串来传递控制器和函数,而不是从 PATH INFO 中解析它们。
如果您想使用默认系统来确定要使用的控制器和功能,您不想将$config['enable_query_strings'] 设置为true。
上一篇 SO 帖子介绍了如何在 CodeIgniter 中启用 $_GET 数组:Enabling $_GET in codeigniter
我认为这就是你想要做的。
【讨论】:
您还必须从配置中设置控制器和函数触发器:
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
因此,一旦启用了查询字符串,您就可以像这样访问它:
http://example.com/index.php?c=controller&m=function&demo=demo
【讨论】: