【问题标题】:enable the query string in codeigniter在 codeigniter 中启用查询字符串
【发布时间】:2010-08-02 07:40:37
【问题描述】:

我已经在配置文件中进行了两项更改,以启用 $_GET 数组

$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = true;

但每当我尝试将我的代码运行为http://example.com/controller/function/$demo=demo 它重定向到默认控制器

【问题讨论】:

    标签: codeigniter query-string


    【解决方案1】:

    在 CodeIgniter 中启用查询字符串意味着您正在使用查询字符串来传递控制器和函数,而不是从 PATH INFO 中解析它们。

    如果您想使用默认系统来确定要使用的控制器和功能,您不想将$config['enable_query_strings'] 设置为true

    上一篇 SO 帖子介绍了如何在 CodeIgniter 中启用 $_GET 数组:Enabling $_GET in codeigniter

    我认为这就是你想要做的。

    【讨论】:

      【解决方案2】:

      您还必须从配置中设置控制器和函数触发器:

      $config['enable_query_strings'] = TRUE;
      $config['controller_trigger'] = 'c';
      $config['function_trigger'] = 'm';
      

      因此,一旦启用了查询字符串,您就可以像这样访问它:

      http://example.com/index.php?c=controller&m=function&demo=demo
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-09
        • 2016-01-18
        • 1970-01-01
        • 1970-01-01
        • 2013-12-27
        • 1970-01-01
        • 2019-05-15
        • 1970-01-01
        相关资源
        最近更新 更多