Codeigniter如何同时启用段基础URL和查询字符串URL [英] codeigniter how to enable segment base urls and query string url at the same time

查看:34
本文介绍了Codeigniter如何同时启用段基础URL和查询字符串URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,我正在使用codeigniter 3.0.3。

Please note I am using codeigniter 3.0.3.

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

In my current project I want to use both query string and segment base url. When I enable

$config['enable_query_strings'] = TRUE

细分受众群停止运行。我已经使用了uri协议的所有选项,例如

segment base stopped working. I have used all options of uri protocol e.g.

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

是否可以使用两种方法而不会出现任何错误。我想在分段的url中使用url帮助器,在某些地方我也想使用查询字符串。

Is there any way to use both with out any errors. I want to use url helpers in segmented url's and at few places I want to use query strings too.

推荐答案

检查URI.php核心类,可以看出,当config uri协议设置为

Checking URI.php core class, it can be seen that query appendix is meant to work when config uri protocol is set to

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

您不需要设置

config['enable_query_strings'] = TRUE;

如果想要获取密钥,可以选择 true =来自URI的值。仅当您要在URI中不包含段的查询字符串时才需要它。

option to true if you want to be able to grab key=value from URI. It is needed only if you want query strings without segments in URI.


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

You can optionally enable standard query string based URLs:

example.com?who=me&what=something&where=这里

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

所以您的选择应该是

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

这篇关于Codeigniter如何同时启用段基础URL和查询字符串URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆