Reputation: 9
i have some problem with route.i want to send different url from one fuction.here sample
this is my fuction
function road($1,$2,$3){
bla bla bla
}
and i want route
localhost/index.php/mycontroller/road/1/2/3
to
localhost/index.php/mycontroller/road/1/2/3
and if $3 =0.i want to route it to
localhost/index.php/mycontroller/street/1/2/0
Upvotes: 1
Views: 1506
Reputation: 3008
You can do a redirect in your function road()
if($3 === 0)
redirect('mycontroller/street/'$1 . '/' . $2 . '/' . $3);
Or set a custom route in config/routes.php
$route['mycontroller/road/(:any)/(:any)/0'] = 'mycontroller/street/$1/$2/0';
Edit :
The redirect()
function is available once you have load the url_helper
. You can do it in config/autoload.php
or by adding this line before calling the function : $this->load->helper('url');
Upvotes: 1