CodeIgniter Enabling Query Strings CodeIgniter Enabling Query Strings codeigniter codeigniter

CodeIgniter Enabling Query Strings


Query strings in 1.7.2 are a joke, it uses ?c=controller&m=method to basically change your pretty urls to psuedo $_GET params. I really can't see why anyone would use it the way it's intended, it's very misleading and is not the same as normal query strings.

I highly suggest you check out the latest version of Codeigniter, where they do not unset the $_GET array (normal query strings are now usable). In one of the core files in the older versions it says CI does not use $_GET so we are going to unset() the global $_GET array. Well, what if I need to use $GET? I always thought it was crazy, and people have been screaming for true $_GET support for forever.

Seriously though, it's time to upgrade:

Latest: https://bitbucket.org/ellislab/codeigniter-reactor/

Stable: http://codeigniter.com/


When upgrading to CodeIgniter 2 is not an option, you can recreate the $_GET variable like so (add this to every controller where you need the query string):

parse_str($_SERVER['QUERY_STRING'],$_GET);

And change this in your config.php file:

// $config['uri_protocol'] = "AUTO"; // change from this

$config['uri_protocol'] = "PATH_INFO"; // to this