Enabling CodeIgniter $_GET

Image

Here is how to enable CodeIgniter support to $_GET and still able to use the normal “SEO-friendly” URL working together.
So you will get a URL like this

http://www.example.com/index.php/the_controller/the_function/?some=thing&more=yes

First approach is modify your “config.php” and change this line.

$config['enable_query_strings'] = true;

But this is not recommended because on pagination, you will get ugly URL.

Second approach is modify your “config.php” and change this line.

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

You can keep this line (notice it is still “false”)

$config['enable_query_strings'] = false;

And on your controller, you can use this code

parse_str($_SERVER['QUERY_STRING'], $get_vars);
echo $get_vars['some'];

Join the Conversation

5 Comments

Leave a comment

Your email address will not be published. Required fields are marked *