CodeIgniter Forums
Random segment 1? possible? - 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: Random segment 1? possible? (/showthread.php?tid=7043)



Random segment 1? possible? - El Forum - 03-21-2008

[eluser]Unknown[/eluser]
Hi guys

Is it possible to have a random 1st segment in the uri?

mysite.com/index.php/234087asdiuhasd_anything_here_as0987asda0sd

Some sort of catch, I'm not sure.

Any help appreciated Big Grin

Cheers


Random segment 1? possible? - El Forum - 03-21-2008

[eluser]xwero[/eluser]
Yes it's possible you use a route to catch whatever you need to display on the page
Code:
$route['(.)+'] = 'controller/method/$1'



Random segment 1? possible? - El Forum - 03-21-2008

[eluser]Unknown[/eluser]
Hey thanks xwero Big Grin, I still a little stuck...

Is it possible for it to preserve the existing controller classes..

So for example look for the controller with the uri name, if there isn't one THEN apply that route rule..before it gives a 404?

Thanks


Random segment 1? possible? - El Forum - 03-21-2008

[eluser]xwero[/eluser]
Because you want a catch all route the only way to use controllers is to use a regular expression or with all your controllers in before the catch all.
Code:
$route['(controller1|controller2)/(.)+'] = '$1/$2';
$route['(controller1|controller2)'] = '$1';
$route['(.)+'] = 'controller/method/$1';