Reputation: 3794
This is my controller directery structure
controllers
-----user(folder)
----------User_reg.php //My Controller inside user folder.
-----index
-----Welcome.php
I can access User_reg.php
like this:
http://localhost/coin_system/user/user_reg
Now I want to eliminate user from this URL so I added the route
$route['user_reg/(:any)'] = 'user/user_reg/$1';
But it show the error: 404 Page Not Found
http://localhost/coin_system/user_reg
How can i access the controller inside the directory in controller?
I have tried to solve using this SO question but it did't help. I am using Codeigniter latest version. 3.1.5
Upvotes: 0
Views: 384
Reputation:
You have missed function
https://www.codeigniter.com/user_guide/general/routing.html#examples
$route['user_reg'] = 'user/user_reg/index';
$route['user_reg/(:any)'] = 'user/user_reg/index/$1';
Or You can have different function
$route['user_reg'] = 'user/user_reg/somefunction'
$route['user_reg/(:any)'] = 'user/user_reg/somefunction/$1';
Also try with index.php in url
http://localhost/coin_system/index.php/user_reg
Upvotes: 2
Reputation: 16436
When you add route with :any
it also find your calling method after controller. But for index(which is default) its not compulsory to all index method So you need to specify route for it also. So just need to add one more route
$route['user_reg'] = 'user/user_reg'; // add this to route file
$route['user_reg/(:any)'] = 'user/user_reg/$1';
Upvotes: 1