30 June 2010 ~ 1 Comment

Query Strings in Codeigniter

In some cases you might prefer to use query strings URLs and not the pretty URLs. CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file.

“Ugly” URLs

index.php?c=users&m=home&id=305

If you open your config file you’ll see these items:

$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';

If you change “enable_query_strings” to TRUE this feature will become active. Your controllers and functions will then be accessible using the “trigger” words you’ve set to invoke your controllers and methods:

index.php?c=controller&m=method

Please note: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs.

Tags: ,

One Response to “Query Strings in Codeigniter”

  1. van 1 July 2010 at 6:05 pm Permalink

    thanks! i have been looking for this for some time. thanks for the info.