CodeIgniter Forums
route question - 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: route question (/showthread.php?tid=43771)



route question - El Forum - 07-22-2011

[eluser]quasiperfect[/eluser]
hi

in my routes.php i have something like this where a,b etc are longer names

Code:
$route['(\w{2})/(a|b|c|d)/(a|b|c|d)(.*)'] = "a/b$1";

the controller a with function b exists and if i call
Code:
http://domain.com/en/a/b
in url it works
but i want to be able to call
Code:
http://domain.com/en/b/b/c/d/e
etc
what i'm doing wrong ?


route question - El Forum - 07-22-2011

[eluser]toopay[/eluser]
You need to add "/". Also you should set up for each tier of your url (you can use shorthand (:any) too)
Code:
// If you want more tier in your url, just define another...
// for 4 tier url, like http://domain.com/en/a/b/c/d/foo
$route['(\w{2})/(a|b|c|d)/(a|b|c|d)/(a|b|c|d)/(a|b|c|d)/(:any)'] = "a/b/$1";
// for 3 tier url, like http://domain.com/en/a/b/c/foo
$route['(\w{2})/(a|b|c|d)/(a|b|c|d)/(a|b|c|d)/(:any)'] = "a/b/$1";
// This will only work for 2 tier url, like http://domain.com/en/a/b/foo
$route['(\w{2})/(a|b|c|d)/(a|b|c|d)/(:any)'] = "a/b/$1";