Using QUERY_STRING on CI4 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Using QUERY_STRING on CI4 (/showthread.php?tid=77977) |
Using QUERY_STRING on CI4 - lucky - 11-14-2020 How can I make CI 4 to use URLs like this: http://mysite.com/index.php?page=home http://mysite.com/index.php?page=mail http://mysite.com/index.php?page=register http://mysite.com/admin/index.php?page=users http://mysite.com/admin/index.php?page=permissions http://mysite.com/admin/index.php?page=permissions&c=1&t=5 I've tried setting on app/Config/App.php the following: PHP Code: public $uriProtocol = 'QUERY_STRING'; But I was not able to make this work. The url structure is not the same as CI 3 Before you could do something like this http://mysite.com?c=controller&m=method¶m1=x¶m2=y Is there any way to do this? RE: Using QUERY_STRING on CI4 - includebeer - 11-14-2020 My first question would be, why would you even want to do this for the controllers and all the routing? If you only want to get a value from the query string you can use getVar() or getGet(): PHP Code: $something = $request->getVar('foo'); See: https://www.codeigniter.com/user_guide/incoming/incomingrequest.html#retrieving-input RE: Using QUERY_STRING on CI4 - captain-sensible - 11-14-2020 the other thing you might be missing is routes default route is: $routes->get('/', 'Home::index'); that means when someone goes to just domain , then what happens is defined in Controller Home and method inside Controller home called index. You can have get and post requests eg Code: $routes->get('addProduct','Product::productAddForm'); my first one means when admin goes to url domain.com/addProduct they get a form .Method productAddForm looks like Code: public function productAddForm() forgot to mention this elelement of route: Code: $routes->get('blogArticle/(:segment)', 'Blog::showArticle/$1'); Code: public function showArticle($theSlug) RE: Using QUERY_STRING on CI4 - lucky - 11-14-2020 (11-14-2020, 05:31 AM)includebeer Wrote: My first question would be, why would you even want to do this for the controllers and all the routing? I know it's not the most convenient thing, but I'm migrating an application and I need to change a lot of URLs. Being able to keep the current routing is the best option for me RE: Using QUERY_STRING on CI4 - includebeer - 11-14-2020 (11-14-2020, 07:22 AM)lucky Wrote: I know it's not the most convenient thing, but I'm migrating an application and I need to change a lot of URLs. Being able to keep the current routing is the best option for me What are you migrating from? An old version of CI of something else? I never used this feature before and I'm not sure if it's still available in CI4. RE: Using QUERY_STRING on CI4 - lucky - 11-14-2020 (11-14-2020, 10:07 AM)includebeer Wrote:(11-14-2020, 07:22 AM)lucky Wrote: I know it's not the most convenient thing, but I'm migrating an application and I need to change a lot of URLs. Being able to keep the current routing is the best option for me The application is not based on CI3. It's a custom framework. So I was trying to avoid migrating something else. RE: Using QUERY_STRING on CI4 - InsiteFX - 11-20-2020 PHP Code: $uri = $request->uri; Will give you it all. |