How to get an infinite route in Codeigniter?

1

I have two urls:

And I'm having these routes:

  • $ route ['search / (: any)']="Search / index / $ 1";
  • $ route ['search / (: any) / (: num']="Search / index / $ 2 / $";

I'd like to use an infinite url but I can not get the desired result. Can someone give me a help? When I access the first url, it works correctly however the second url does not work. What I need is represented in the image below:

SoIwasseeinghereand$_POSTisgoingcorrectlybutitisnotenteringtheindex,ieifItrytooverwriteanddeletethe/indexerror.Inshort,Ithinktheerrorisinthesamerouting.

    
asked by anonymous 19.11.2016 / 00:04

1 answer

0

Try using:

$route['busca/(:any)'] = "Busca/index/$1";
$route['busca/(:any)/(:num)'] = "Busca/index/$1/$2";

So you will access:

search

And it can be rendered like this:

public function index($palavra, $numero = false){

}

For you to do endless routes like you said, you will eventually generate errors because as you do not know what is being passed in the URL and when then it would be difficult.

You will have to create the routes according to the parameters that will be received.

    
19.11.2016 / 00:22