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->total_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.