adaxa
adaxa

Reputation: 1608

Dynamic URLs in CodeIgniter?

How to get URLs like /user/bob user/martin dynamically in CodeIgniter?

Upvotes: 2

Views: 1035

Answers (2)

ilbesculpi
ilbesculpi

Reputation: 328

you should use the

$route['user/(:any)'] = "user/user_controller_method/$1";

as James suggested, and then define the funcion on the user controller:

function user_controller_method($username) {
   // ... $username should be the url param
}

Upvotes: 4

James Goodwin
James Goodwin

Reputation: 7406

You need to set up custom routing for the controller in application/config/routes.php, e.g.

$route['user/(:any)'] = "user/user_controller_method/$1";

Upvotes: 7

Related Questions