Casey Flynn Casey Flynn - 1 year ago 201
PHP Question

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) ---(routed)--->

Anyone know what I'm missing?

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

Answer Source

try this

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