1

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

2 Answers 2

3

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');
}
Sign up to request clarification or add additional context in comments.

Comments

0

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. :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.