Md. Ruzdi  Islam
Md. Ruzdi Islam

Reputation: 61

CodeIgniter routing when routing url starts with variable

I am getting problem on codeigniter routing when routing url starts with variable like following -

$route['(:any)/(:any)']  = "home/index/0/N/DealsAmount/ASC/$1/$2";

i can to able to configure other routing url when i am passing values through url. Example: Following things work perfectly

$route['About-Us/Team'] = "aboutus/team";
$route['About-us/Jobs'] = "aboutus/jobs";
$route['About-Us/FAQ'] = "aboutus/faq";

But i use this url using varible like following --

$route['About-Us/Team/(:any)'] = "aboutus/team/$1";
$route['About-Us/Team/(:any)/(:any)'] = "aboutus/team/$1/$2";
$route['About-us/Jobs/(:any)'] = "aboutus/jobs/$1";
$route['About-Us/FAQ/(:num)'] = "aboutus/faq/$1";

then it redirects to the home page that means this routing is not working here $route['(:any)/(:any)'] is working how can i able to rout these types of url can you please advise me.

Upvotes: 1

Views: 1348

Answers (1)

Mischa
Mischa

Reputation: 43298

You have to put the routes with :any at the bottom. If you put it at the top other routes never get caught. This should be OK:

$route['About-Us/Team/(:any)/(:any)'] = "aboutus/team/$1/$2";
$route['About-Us/Team/(:any)'] = "aboutus/team/$1";
$route['About-us/Jobs/(:any)'] = "aboutus/jobs/$1";
$route['About-Us/FAQ/(:num)'] = "aboutus/faq/$1";
$route['(:any)/(:any)']  = "home/index/0/N/DealsAmount/ASC/$1/$2";

Upvotes: 1

Related Questions