codeigniter how to enable segment base urls and query string url at the same time

时光怂恿深爱的人放手 提交于 2019-12-25 04:41:13

问题


Please note I am using codeigniter 3.0.3.

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

$config['enable_query_strings'] = TRUE

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

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

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.


回答1:


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';

You don't need to set

config['enable_query_strings'] = TRUE;

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.

You can optionally enable standard query string based URLs:

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

So your options should be

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


来源:https://stackoverflow.com/questions/36947577/codeigniter-how-to-enable-segment-base-urls-and-query-string-url-at-the-same-tim

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!