March 20, 2012
create a dynamic url in codeigniter like facebook
Question by Nisha haridas
I need to create a dynamic url in codeigniter like the facebook application. Is it possible to create such url using the codeigniter framework?
eg:
1. www.facebook.com/nisha
2. www.facebook.com/dev
Answer by Starx
Its pretty easy to setup this by the use of routes. Read their routing guide
$route['([a-zA-Z]+)'] = "controller/user/$1";
However, if their is only one way of accessing the website, is like domain.com/username
then its ok, otherwise, this will prove be a hard catch on the long run. On that case, limit the Route to a limited scope like
$route['users/([a-zA-Z]+)'] = "controller/user/$1";
This will help in the extending the system in numerous way