Function cannot call through URL |
[eluser]Unknown[/eluser]
I'm a fresh learner in using CI, below is a controller with function insertValues() that I try to call directly in URL, which looks like http://sitename/codeIgniter/pages/insertValues, but it returned 404 Page Not Found when its call, after few searched in google, I found that is an issue of route.php which I do not know how to configure it. Please refer to below route.php, the function insertValues() will work only if remove $route['(:any)'] = 'pages/index/$1';, but somehow once I call page like http://sitename/codeIgniter/home, it will show 404 Page Not Found. route.php Code: $route['default_controller'] = 'pages/index'; Controller: Code: class Pages extends CI_Controller{ Please help in advice, many thanks.
[eluser]pickupman[/eluser]
You should add another route for that method. By using (:any) as a route, you will need to explicitly write every other controller/method as a route for it to work. Code: $route['default_controller'] = 'pages/index';
[eluser]pickupman[/eluser]
If you plan on having other controllers, you also find it helpful to at least have the pages segment in your URL. Then you wouldn't have to use the (:any) route. You could use 'pages/(:any)'.
|
Welcome Guest, Not a member yet? Register Sign In |