【问题标题】:codeigniter how to enable segment base urls and query string url at the same timecodeigniter如何同时启用段基本url和查询字符串url
【发布时间】:2016-04-29 21:16:35
【问题描述】:

请注意我使用的是 codeigniter 3.0.3。

在我当前的项目中,我想同时使用查询字符串和段基 URL。当我启用

$config['enable_query_strings'] = TRUE

segment base 停止工作。我已经使用了 uri 协议的所有选项,例如

$config['uri_protocol'] = 'PATH_INFO'; //REQUEST_URI,QUERY_STRING

有什么方法可以同时使用两者而不会出现任何错误。我想在分段 url 中使用 url 助手,并且在一些地方我也想使用查询字符串。

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

    查看 URI.php 核心类,可以看出查询附录在 config uri 协议设置为时起作用

    $config['uri_protocol'] = 'REQUEST_URI';
    

    你不需要设置

    config['enable_query_strings'] = TRUE;
    

    true 的选项,如果您希望能够从 URI 中获取 key=value。仅当您希望在 URI 中没有段的查询字符串时才需要它。

    您可以选择启用基于标准查询字符串的 URL:

    example.com?who=me&what=something&where=here

    所以你的选择应该是

    $config['uri_protocol'] = 'REQUEST_URI';
    config['enable_query_strings'] = FALSE;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-24
      • 2019-05-15
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多