tags:

views:

32

answers:

2

Hi,

I have enabled the use of query strings by setting the config variable "enable_query_strings" = TRUE.

I understand that in order to invoke method X of class Y, my URL will look like this:

http://localhost/ci_sample/index.php?c=Y&m=X

However, what if my function signature for X is

function X($param1, $param2) {...}

how should my query string look like in order to pass two parameters to X()?

(Btw, I have decided to use this approach, because I couldn't find an article/forum on mod_rewrite for removing index.php that would work on my machine. I'm using XAMPP on a Windows platform)

Regards,

Erwin

+1  A: 

It seems that if you want to use "enable_query_strings" = TRUE, you cannot pass parameters to function X().

This is what is says in the user guide

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.

To get around this you'd have to do this:

http://localhost/ci_sample/index.php?c=Y&m=X&param1=bla&param2=foo

function X()
{
   $param1 = $this->input->get('param1');
   $param2 = $this->input->get('param2');
}
captaintokyo
A: 

You don't have to use query strings just because you can't remove index.php from the URL, you can use URL's like this: example.com/index.php/controller/method/param1/param2. If you enable query strings in config.php and also set uri_protocol to "PATH_INFO" you can use both. Like this: example.com/index.php/controller/method/param1/param2/?param3=wellhellothere

Your problem with getting mod_rewrite to work is probably related to the fact that you're running CI in a subdirectory. RewriteBase /ci_sample/ directly after RewriteEngine On should do the trick. :)

intedinmamma