With .htaccess
you can do like this
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# Profile page
RewriteCond %{REQUEST_URI} !^/(css|js|img)/
RewriteRule ^profile/([^/]*)$ profile/index/$1 [L]
In rewrite you have to mention the function name whether it is the index function or any other
Same as you can utilize the CI routing routes.php
$route['profile/(:any)'] = "profile/index/$1";
Now in index function of profile you can get the parameter
function index($id) {
echo $id;
echo $this->uri->segment(3);
//Both will result the same
}