Using QUERY_STRING on CI4 |
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?
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/i...ving-input
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
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) (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
(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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/ (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. PHP Code: $uri = $request->uri; Will give you it all. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |