![]() |
want to create a url like http://www.example.com/uername - 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: want to create a url like http://www.example.com/uername (/showthread.php?tid=52660) Pages:
1
2
|
want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] I want to create a page for the users to view their profile [http://www.example.com/uername] similar to facebook.com after creating their accounts. What would be the best way to achieve that? want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] Any ideas please? want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]boltsabre[/eluser] so you waited 7 minutes before bumping your own post... http://ellislab.com/codeigniter/user-guide/general/routing.html want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] cool... but haven't got a clue from there... This is what I have now.... http://www.example.com/user/profile/12 and now I want it to be http://www.example.com/12 I looked at the codeigniter guide for routing and set up new route similar to this one $route['(:num)'] = "user/profile/$1"; - not working. This whole routing business seem very tricky to me. Can you please explain it further? want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]boltsabre[/eluser] not working... any error messages? what's not working $route[(:num)] = "user/profile/$1"; I would have expected that to work... is your profile function accepting variables? The $1 is a function variable. For example Code: public function profile($user_id){ If that's not the problem, try this rule, does it work? $route[u/(:num)] = "user/profile/$1"; I don't have a great deal of experience with routing, perhaps it needs actual 'controller' to 'controller' mapping (for want of a better expression), what I mean is, maybe the first parameter cannot actually be a variable (number in your case), you may have to settle for a url that looks like :domain.com/u/11234 want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]InsiteFX[/eluser] When using a route like that it needs to be the very last route in the list. want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] it is the last one... want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] [quote author="boltsabre" date="1340205049"]not working... any error messages? what's not working $route[(:num)] = "user/profile/$1"; I would have expected that to work... is your profile function accepting variables? The $1 is a function variable. For example Code: public function profile($user_id){ If that's not the problem, try this rule, does it work? $route[u/(:num)] = "user/profile/$1"; I don't have a great deal of experience with routing, perhaps it needs actual 'controller' to 'controller' mapping (for want of a better expression), what I mean is, maybe the first parameter cannot actually be a variable (number in your case), you may have to settle for a url that looks like :domain.com/u/11234[/quote] I will give it a go....thanks want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]Rayhan[/eluser] I have got some info about mod_rewrite and will try this too want to create a url like http://www.example.com/uername - El Forum - 06-20-2012 [eluser]InsiteFX[/eluser] Code: $route['*(:any)'] = 'user/profile/$1'; |