CodeIgniter URI Routing and empty segment CodeIgniter URI Routing and empty segment codeigniter codeigniter

CodeIgniter URI Routing and empty segment


build your functions in your controller instead of this:

public function index(){...

try something like this:

public function index($slug = ''){if ($slug = '') {   // redirect code here}else {   // if there is something in $slug then load this code}

and maybe your routes should be something like:

$route['user'] = 'users';$route['user/(:any)'] = 'users/index/$1';


You can add another route such as:

$route['user'] = "users"


Try with

$route['user:any'] = "users";