I have a question of this kind: There is a url like

http: // site-name / main / sub_menu? choice = catalog & section = 3 ,

where main is the controller, and sub_menu is the method with parameters. The question is how do I change routes to make the url look like:

http: // site-name / main / catalog / products ?

I tried this: $ route ['catalog / products'] = 'main / sub_menu? Choice = catalog & section = 3'; On the page with this address gives the error 404 not found.

I understand that it is necessary to transfer parameters for a gett differently in the routes. But how to do it right?

  • it's not entirely clear what you want. $route['main/catalog/(:any)'] = ...; - this? - Manitikyl
  • @Manitikyl, as I understand it, this solution is suitable for a post request. I do not need to enter parameters in the address bar. I have a static catalog / products url. It is necessary that when it is typed in the browser line, pkhp translates this address to main / sub_menu? Choice = catalog & section = 3. Parameters do not change. - Alex Fomenko
  • Did you translate - redirect? or rejected but url left catalog / products - Manitikyl
  • @Manitikyl, not a redirect, it is necessary that when entering catalog / products, click on the link to the right of "=", but catalog / products is displayed. - Alex Fomenko
  • If you want to change the routing, then you need to play the configuration parameters enable_query_strings, controller_trigger and function_trigger. Then you can pass get (what is after?). codeigniter.com/userguide2/general/urls.html But if you mean that you just need to take a get parameter, then in the handler (method / function) you analyze (for example, through parse_url ()) $ _GET and there you already decide what im doing - MAX

1 answer 1

In general, did not solve this problem beautifully. I just made a method in the controller that takes parameters, instead of looking for them through a het. Then there are two ways to access the desired page:
1. Via http: // site-name / main / sub_menu? Choice = catalog & section = 3 ;
2. Via http: // site-name / catalog / products , which translates to http: // site-name / catalog / 3 .