CodeIgniter Forums
regex and routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: regex and routing (/showthread.php?tid=16134)



regex and routing - El Forum - 02-25-2009

[eluser]stoefln[/eluser]
i always had my routing config like this:
$route['users/([a-zA-Z0-9]+)'] = "users/profile/$1";

now i like to get rid of the "users" cause this is the main controller and i would like to get the urls as short as possible.
but:
$route['([a-zA-Z0-9]+)'] = "profile/$1";
<b>edit (sorry made a mistake)</b>
$route['([a-zA-Z0-9]+)'] = "users/profile/$1";
<b>edit end</b>
does not work, i get to the wrong profile when i enter the url without "users/"
any ideas?


regex and routing - El Forum - 02-25-2009

[eluser]xwero[/eluser]
if you don't want to have users in the url why do you change the controller? In your second route profile is the controller so the method is the fetched username, which gives you 404 errors i assume?


regex and routing - El Forum - 02-25-2009

[eluser]stoefln[/eluser]
[quote author="xwero" date="1235596958"]if you don't want to have users in the url why do you change the controller? In your second route profile is the controller so the method is the fetched username, which gives you 404 errors i assume?[/quote]

sorry actually the correct version is:
$route[’([a-zA-Z0-9]+)’] = “users/profile/$1”;

corrected it in the original post.
nevertheless it doesnt work.