Welcome Guest, Not a member yet? Register   Sign In
dynamic routing
#1

[eluser]brian88[/eluser]
I have 3 controllers
main, login, cms

heres my routes, it doesnt work.

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

I just want
mysite.com/page
not
mysite.com/cms/page

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

[eluser]PhilTem[/eluser]
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

Code:
$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.
#3

[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

http://myphplibrary.blogspot.in/2012/03/codeigniter-routing-issue-fixation-url.html
#4

[eluser]brian88[/eluser]
How do I do this bootstrap way exactly?
#5

[eluser]brian88[/eluser]
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?




Theme © iAndrew 2016 - Forum software by © MyBB