By this way you can achieve it.
$route['(:any)'] = 'user/'.$username;
Creating this route dynamically is bit complex
We have to create this route only if user exits in the database, so it will not affect other controllers. Write below code in your routes.php
$username = explode('/', $_SERVER['REQUEST_URI']);
require_once( BASEPATH .'database/DB'. EXT );
$db =& DB();
$query = $db->where('username', $username[1] ); //check user name
$query = $db->get( 'tbl_users' ); //table name in which user exits
if($query->num_rows > 0){ //if exits the create routing
$route['(:any)'] = 'user/'.$username[1]; // here you can define any controller and function name as required for the demo I have given this "'user/'.$username[1]"
}
Note: Remove index.php from url using .htaccess file.