如何在 codeigniter 中获取查询字符串变量值?

How can i get query string variable value in codeigniter?

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

我的 Url :

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

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

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

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