![]() |
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 (/showthread.php?tid=6425) |
SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-03-2008 [eluser]Pygon[/eluser] [quote author="badgeek" date="1204358813"]i use this on my site, just enable query string on your config Code: RewriteEngine On This will work great if you only want query strings to go to a specific controller. You can actually do this quite a bit easier by simply using: index.php?main&search&myquerystr;=what+ever Lovecannon is correct that there are other ways to use GET strings, however my main attempt was to have a drop-in solution that doesn't require configuration or base file changes to work on any implementation of CI. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-03-2008 [eluser]Lovecannon[/eluser] Yeah, a drop-in replacement also works, but personally, I think its a better practice to set the URI protocol to PATH_INFO just be sure things dont break when a query string is used. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-03-2008 [eluser]Pygon[/eluser] I would disagree on a personal level, simply that I don't find it better to force PATH_INFO usage. This won't work correctly if "$config['enable_query_strings'] = TRUE;" is set, without making a change to the uri_protocol. Regardless, same results with a different implementation. To each his/her own. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]Avatar[/eluser] I get an error when running your code: Code: Severity: Warning SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]xwero[/eluser] I wonder why the URI library is hacked the $_GET global is set to an empty array in the Input class (from line 110) Code: if ($this->allow_get_array == FALSE) ![]() SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]Pygon[/eluser] unfortunately no xwero CI_URI/CI_Router keys off $_GET[0] and $_GET[1] prior to CI_Input class ever loading, so /index.php/1/2?3&4;will actually take you to controller 3, function 4. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]Pygon[/eluser] [quote author="yingyes" date="1204724364"]I get an error when running your code: Code: Severity: Warning Hi yingyes -- This isn't quite enough info, although you can test the following. MY_Input.php Code: <?php Let me know if this fixes your issue. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]xwero[/eluser] [quote author="Pygon" date="1204743806"]unfortunately no xwero CI_URI/CI_Router keys off $_GET[0] and $_GET[1] prior to CI_Input class ever loading, so /index.php/1/2?3&4;will actually take you to controller 3, function 4.[/quote] I just tested it with the urls like /index.php/some/segment?one=1&two=2&three=3 /index.php/some/segment/?one=1&two=2&three=3 and to check i added to the method following Code: var_dump($this->input->get('one')); string(1) "1" string(1) "2" string(1) "3" The only reason i could think about why CI cuts off the fist two segments is because the enable_query_strings config variable is set to true. SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]Avatar[/eluser] still not working for m, it looks as though it's not even setting the $_GET variable because of enable_query)strings being set to true and in the CI Base Input class it does this: Code: if ($this->allow_get_array == FALSE) SEO URIs *AND* $_GET requests - /controller/function/?myvar=1 - El Forum - 03-05-2008 [eluser]Pygon[/eluser] yingyes: I'm a bit confused as to how you are attempting to make this work because your description is vague. In fact, I'm not sure why you would even be posting anything here if you are using enable_query_strings as true, since that would completely bypass any of my code. xwero: My appologies -- try only: index.php/some/segment/?one=1 and you should recieve a 404 since CI_URI assumes that if count($_GET) == 1, the first key is the name of the base controller you would like to access: CI_URI.php Code: // If the URL has a question mark then it's simplest to just However, from what you've said, and reviewing the code, I've realized that CI_URI could simply be modified. Using enable_query_strings = true and uri_protocol = auto, GET requests should work perfectly fine as long as there is more than one GET variable. I suspect if CI_URI was extended and that section of code commented out, everything should work the same, although I haven't exactly determined WHY this zero index thing would be done anyway. Could be accomplished with: $config['enable_query_string'] = true; $config['uri_protocol'] = 'AUTO'; MY_URI.php Code: <?php course you lose the "single _GET not using _SERVER variable performance benefit" thing. |