【问题标题】:How can i get query string variable value in codeigniter?如何在 codeigniter 中获取查询字符串变量值?
【发布时间】:2016-02-25 08:48:26
【问题描述】:

我想获取查询字符串变量值并在配置文件中允许查询字符串规则。

我的网址:

http://localhost/Demo/admin_login/?mts=ok

我在配置文件中做了:

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

在控制器中,我回应了这个

echo $_GET['mts'];

我收到了这个错误:

Message:  Undefined index: mts

【问题讨论】:

  • 您使用标准的codeigniter 格式为http://localhost/Demo/admin_login/ok 并获得价值并获得价值echo $mts =$this->uri->segment(3);
  • 在您的代码中您错过了操作index。尝试使用http://localhost/Demo/admin_login/index?mts=ok

标签: php codeigniter query-string


【解决方案1】:

更改您的 .htaccess 以删除 ? (如果存在)在重写规则中

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

试试 How to make CodeIgniter accept "query string" URLs?

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-02-08
相关资源
最近更新 更多