Welcome Guest, Not a member yet? Register   Sign In
Using URI routing and username as segment 1
#1

[eluser]Unknown[/eluser]
Hi, I'm looking for advice on the best way to set up a site in CodeIgniter. I am creating a site where users receive a simple URL of their own, e.g. example.com/username. To do this I have set up the routing as:

Code:
$route[(:any)] = '/users/view_user/$1';

And now of course every page accessed on the site is sent to that controller. For all other pages on the site I need to explicitly add to the routing function to get it to work e.g.

Code:
$route['blog'] = 'blog';
$route['contact'] = 'contact';

Which doesn't seem like the best way to do it. Is there a better way to give usernames segment 1 URLs, and continue to use the controller/function URLs normally?

Thanks in advance,
Paul




Theme © iAndrew 2016 - Forum software by © MyBB