• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dynamic routing

I have 3 controllers
main, login, cms

heres my routes, it doesnt work.

$route['(:any)'] = "main/$1";
$route['(:any)'] = "login/$1";
$route['(:any)'] = "cms/$1";

I just want

Whats the best way of achieving this? Because my way obviously doesnt work

It doesn't work because routing works with "first come first serve" i.e. the first matched route will be used. You'd have to make something like a bootstrap-router, which will process your requests any further with this route

$route['(:any)'] = "router/bootstrap/$1";

This way your router-controller and bootstrap-method will be called with the whole URI-string as arguments. You can then do your processing of requests by checking e.g. the first URI-segment and including the appropriate file.

[eluser]Reneesh T K[/eluser]
If there is a third parameter except class name and function name, I faced some problem when routing and I fixed it using the following tutorial


How do I do this bootstrap way exactly?

is there a library for this "router" controller and "bootstrap" method? Because this seems like a common thing to do.

How does this logic work?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.