CodeIgniter Forums
Is there a way to accept single GET parameter? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Is there a way to accept single GET parameter? (/showthread.php?tid=10170)



Is there a way to accept single GET parameter? - El Forum - 07-21-2008

[eluser]Sam Dark[/eluser]
If there is only one GET parameter in URL its name will be considered as first URI segment. As I can see this is to make URL like http://example.com/?blog/post/test to work without mod_rewrite.

This is a god think but sometimes I need to accept first GET parameter. For example, some major link directories are adding ?from=dir to each link. So when going through http://example.com/?from=dir I'm getting 404 since I have nothing mapped to "from". I can map controller to "from". It will solve one issue but not all similar issues…

Is there a way to accept first parameter as it is?


Is there a way to accept single GET parameter? - El Forum - 07-21-2008

[eluser]Sam Dark[/eluser]
Exel from Russian community found this:

URI.php
Code:
// If the URL has a question mark then it's simplest to just
// build the URI string from the zero index of the $_GET array.
// This avoids having to deal with $_SERVER variables, which
// can be unreliable in some environments
if (is_array($_GET) AND count($_GET) == 1 AND trim(key($_GET), '/') != '')
{
    $this->uri_string = key($_GET);            
    return;
}

It prevents using GET with only one argument set.


Is there a way to accept single GET parameter? - El Forum - 07-26-2008

[eluser]Sam Dark[/eluser]
Yes, there is… by changing $config['uri_protocol'] to 'PATH_INFO'.