How to extract get variable from query string in codeigniter?

江枫思渺然 提交于 2019-11-28 10:18:10

问题


My issue is i have QUERY_STRING enabled in my codeigniter setup so that links look like this http://www.domain.com/search/index/page/4?squery=searchterm

I have a form on this page that uses GET because I can't use POST for what i'm using, when i try to retrieve the "squery" using $this->uri->segment(4) it doesn't return that part only the 4 part. What way can i retrieve the search term ?

This is in my htaccess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1 [L]

回答1:


Got it to work by doing this Changing my config variables

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

And changing my htaccess to this

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]

Help found here How to make CodeIgniter accept "query string" URLs?



来源:https://stackoverflow.com/questions/3689629/how-to-extract-get-variable-from-query-string-in-codeigniter

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