Assume base_url is "http://www.facebook.com"
Default controller is "Home"
How do i code my routes and controller to get my URL as "http://www.facebook.com/noddycha"
Where "noddycha" is a get parameter. The page should load my profile page from DB.
Assume base_url is "http://www.facebook.com"
Default controller is "Home"
How do i code my routes and controller to get my URL as "http://www.facebook.com/noddycha"
Where "noddycha" is a get parameter. The page should load my profile page from DB.
In your application/routes.php file add this line after $route['404_override'] = '';:
$route['(:any)'] = 'users/profile';
Now absolutely everything will be redirected the profile function of the users controller (or whichever controller/function combination you substituted in the routes.php file). Then you can get the parameter by doing this in the profile function:
if ($this->uri->total_segments() === 1) {
$profile = $this->uri->segment(1);
}
If you have some other controllers which you would still like to be able to access, e.g. an about us page, add them after the above line in the routes.php file. For example, if we extend the example above:
$route['(:any)'] = 'users/profile';
$route['home/about'] = 'home/about_us';
Would mean that every request is sent to the users/profile function, except http://example.com/home/about will go to the about us page.
index()method, let it accept the parameter for your $user_profile.