如何从codeigniter中的查询字符串中提取变量?

发布于 2024-09-18 20:56:41 字数 523 浏览 1 评论 0原文

我的问题是我在 codeigniter 设置中启用了 QUERY_STRING,以便链接看起来像这样 http://www.domain.com/search/index/page/ 4?squery=searchterm

我在此页面上有一个使用 GET 的表单,因为当我尝试使用 $this-> 检索“squery”时,我无法对我正在使用的内容使用 POST ;uri->segment(4) 它不返回该部分,仅返回 4 部分。我可以通过什么方式检索搜索词?

这是在我的 htaccess 中

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

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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇女薄笑 2024-09-25 20:56:41

通过这样做让它工作
更改我的配置变量

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

并将我的 htaccess 更改为

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

此处的帮助
如何使 CodeIgniter 接受“查询字符串”URL?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文