Reputation: 1278
I'm very confused as the documentation for this is very straight forward and simple, I must be missing something.
I have controller that I route to using routes.php
like so.
$route['users'] = '/usermanager';
This works as expected, navigating to mysite/users
renders my controller.
I have some front end routing to handle different tabs on the user page, so the url can have some sub routes like /users/management
. The logic for this is all handled on the front end, all I need is for anything under /users
to route to the same controller.
So I write it like so:
$route['/users/(:any)'] = '/usermanager';
This fails and I get directed to my 404 page.
I also tried specifying my route explicitly:
$route['/users/management'] = '/usermanager';
Still no dice. What am I not understanding about this routing feature.
Heres my full routes.php incase there's something i'm missing:
$route['default_controller'] = 'EdgeView';
$route['404_override'] = 'PageNotFound';
$route['translate_uri_dashes'] = FALSE;
$route['view'] = '/';
$route['list'] = '/';
$route['pictorial'] = '/';
$route['certificate'] = '/';
$route['files'] = '/';
$route['about'] = '/';
$route['contact'] = '/';
$route['users'] = '/usermanager';
$route['/users/(:any)'] = '/usermanager';
Upvotes: 0
Views: 2951
Reputation: 435
Remove the leading slash in your route.
Change this
$route['/users/(:any)'] = '/usermanager';
to this
$route['users/(:any)'] = 'usermanager';
Upvotes: 1
Reputation: 65
Codeigniter Most Of Pepole Used this 3 type of route
//Simple Route
$route['login'] = 'Login/index';
//pass route with id or noumber
$route['product/(:num)'] = 'catalog/product_lookup_by_id/$1';
// pass any route
$route['product/(:any)'] = 'catalog/product_lookup';
// pass moulte value in route
$route['product/(:any)/(:any)'] = 'catalog/product_lookup';
Upvotes: -1
Reputation: 844
Make sure you use the provided .htaccess file by Codeigniter and place it to your root app.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
save that as .htaccess
the logic of routing is. your have the Welcome.php as a default Controller. If you are going to route your custom Controller do this following.
$route['default_controller'] = 'welcome' //where execute the Welcome/index
Example:
$route['login'] = 'Auth/login'
you are just going to call login to your url and it will execute the Auth/login dynamically.
Upvotes: 1
Reputation: 1014
I am not sure if I understood, but assuming your controller is usermanager
, you have to specify where the group should be:
$route['/users/(:any)'] = '/usermanager/$1';
So, if a request is /users/testing
would be like /usermanager/testing
Upvotes: 0