I am putting together a simple networking site and would like to have the urls work similar to facebook so by typing in domain.com/username I would get a user profile. I can do this already this way
Logged in users profile at
domain.com/
other users profile at
domain.com/home/username
The default controller is called home and I am currently using the _remap function to check for extra url parameters to display different data based on what is or isn’t passed.
My question is how would I map this out so I can access user profiles by:
domain.com/username
Is there a routes.php setting I could use? htaccess?
you should add the following rule in your config/routes.php
this will reroute all your request to the home controller.
so
domain/michellewill re be rerouted asdomain/home/michellebut in this case all your requests will be rerouted to the home controller
eg.
domain/pages/aboutwill also be rerouted todomain/home/pages/aboutwich false.so you MUST add for each request a identic rule before the Profile Route,
eg.
$route['pages/(:any)'] = 'pages/$1';put it all together :