CodeIgniter Forums
Custom URL routing and interpretation? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Custom URL routing and interpretation? (/showthread.php?tid=16017)



Custom URL routing and interpretation? - El Forum - 02-22-2009

[eluser]Unknown[/eluser]
Hello,

I'm new to CI, and was wondering about custom URL routing and interpretation. Supposing I have an Online Directory with URL's constructed such as,

Code:
http://website.com/Canada/Montreal/Cars/Honda/Dealer

How would I get CI to interpret this appropriately as being individual parameters that I wish to capture and use? as the above URL does not conform to the "controller - method" system of routing that CI uses.

Any help in this regard will be appreciated..

Thanks


Custom URL routing and interpretation? - El Forum - 02-22-2009

[eluser]TheFuzzy0ne[/eluser]
Assuming you're only going to have a single controller, just rerouting all calls to that controller should work.
Code:
$route[':any'] = 'controller/method''

I'd imagine that should do it, but I haven't tested it.

You should then be able to use $this->uri->segment(n) to get your segments. Segment number 1 should be the country name. Again, I can't confirm this, as I don't use routes, but if I understand them correctly, that should work.