Casey Flynn
Casey Flynn

Reputation: 14038

CodeIgniter routes map all URI segments to one controller/method

I have CI app with one controller, 'primary.'

I want to map all requests to the method primary->index() and pass the segments as arguments to the index method.

I've tried setting up a route in config/routes.php: $route['(:any)'] = "primary/index/$1";

but for some reason this is not working Ex: (I want) www.example.com/test/delta ---(routed)---> www.example.com/primary/index/test/deta

Anyone know what I'm missing?

Figured it out! $route['(.*)'] = 'primary/index/$1'; Also I forgot to remove index.php with .htaccess

Upvotes: 3

Views: 5878

Answers (2)

Adi Prasetyo
Adi Prasetyo

Reputation: 1050

It's also achievable via remap on your controller

Upvotes: 0

Peter Wateber
Peter Wateber

Reputation: 3938

try this

$route['(.*)'] = "primary/$1";

Upvotes: 11

Related Questions