How to pass a parameter directly to the default controller |
[eluser]Shiju S S[/eluser]
I need to pass a parameter directly to the default controller like quickbharat.com/shiju I defined routes like Code: $route['default_controller/frontpage/(:any)'] = "frontarea/frontpage/some/$1"; 404 error occurs. What to do sir?
[eluser]InsiteFX[/eluser]
Code: // replace default_controller with shiju
[eluser]Shiju S S[/eluser]
The name coming after the default controller is a variable I want to pass like quickbharat.com/research associate quickbharat.com/lab assistant quickbharat.com/shiju My default controller now points to: Code: $route['default_controller'] = "frontpage"; frontpage is the controller loaded first. How can I call a method in that controller directly without using Code: $route['frontpage/(:any)'] = "frontarea/frontpage/somefunction/$1";
[eluser]InsiteFX[/eluser]
Spaces will show up as so your url will end up looking like research associate Better to use an under score then it will look like research_associate CodeIgniter Routes Trick – Removing Controller Names from the URI to Keep URLs Short.
[eluser]Shiju S S[/eluser]
Sir actually i want to pass a parameter to the default controller like this Code: http://example.com/param1/param2 I did like this Code: public function index() Is there any other way like defining a separate controller to handle it in the routes. like Code: $route['default_controller/(:any)'] = "frontpage/some/$1";
[eluser]Shiju S S[/eluser]
Thank you sir for I got it solved with this simple thing folder - frontarea controller - frontpage function - somefunction $route['(:any)'] = "frontarea/frontpage/somefunction/$1";
[eluser]CroNiX[/eluser]
That will work unless you have more than one controller (unless you have routes defined for those before your catch-all route) |
Welcome Guest, Not a member yet? Register Sign In |