![]() |
CodeIgniter 2 and segment-based URLs with query strings - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: CodeIgniter 2 and segment-based URLs with query strings (/showthread.php?tid=35685) |
CodeIgniter 2 and segment-based URLs with query strings - El Forum - 11-08-2010 [eluser]Prophet[/eluser] Hi all. I was a little frustrated to find that the old Code: $config['uri_protocol'] = "PATH_INFO"; ![]() Using this configuration in CI2 will give you URLs like www.example.com/?/ and www.example.com/?controller/method which I don't think is ideal. I came up with a really simple fix. I don't know if it's the right thing to do, but it makes sense to me. In system/core/Config.php, change line 221 from: Code: if ($this->item('enable_query_strings') == FALSE) Code: if ($this->item('enable_query_strings') == FALSE OR $this->item('uri_protocol') == 'PATH_INFO') I recommend creating application/core/MY_Config.php and overriding the site_url() method to avoid overwriting your changes when you pull the latest CI2 source in. CodeIgniter 2 and segment-based URLs with query strings - El Forum - 11-08-2010 [eluser]Dennis Rasmussen[/eluser] Or you could just hook pre-system and save the querystring before _GET gets destroyed and then recreate _GET pre-controller ![]() All done in a hook file which will work with any version and subversion. CodeIgniter 2 and segment-based URLs with query strings - El Forum - 11-08-2010 [eluser]Prophet[/eluser] [quote author="Dennis Rasmussen" date="1289229330"]Or you could just hook pre-system and save the querystring before _GET gets destroyed and then recreate _GET pre-controller ![]() All done in a hook file which will work with any version and subversion.[/quote] I find hooks to be messy and prefer extending/modifying the core classes. Good to know that method exists though - thanks ![]() CodeIgniter 2 and segment-based URLs with query strings - El Forum - 11-08-2010 [eluser]amosmos[/eluser] don't forget to join us on this request: http://ellislab.com/forums/viewthread/165822/ It's a really important fix and should be an easy one for ellislabs. just separate the config option to two: 1. allow\disallow query strings (which IMHO should be default to allow) and 2. use query strings for uri routing instead of the default segments method. thanks, amos |