having problem creating a default controller |
[eluser]UdayD[/eluser]
Hi! m just using CI for developing one project. I have just created one controller named main and have been calling it a default controller by changing the value of default controller from welcome to main(name of my controller) but when i hit a url http://locahost/mysite/index.php it gives 404 error but when again i put the default controller as welcome it shows the page. I have created the controller 'main' inside the applications folder inside the system folder. Please let me know what is the problem. thanks in advance !
[eluser]cahva[/eluser]
So you main controller is in here for sure?: system/application/controllers/main.php Post your main controller code.
[eluser]Ivar89[/eluser]
Default controller is defined in map config->routes.php If your default controller is main it should look like thisroutes.php) Code: $route['default_controller'] = "main"; Code: class main extends Controller
[eluser]UdayD[/eluser]
i have written my controller like Code: class main extends Controller do i need that name of function as index can i change it to name page. or from where i need to change the function name from where the index function is called so that i can change to name " page" function
[eluser]Ivar89[/eluser]
you can change it to something else yes, but index is loaded automaticly so if you change it to page your URL will be: http://locahost/mysite/index.php/page and BTW Thats the way I do it Code: $this->load->view('main/index');
[eluser]UdayD[/eluser]
sorry for the earlier mistake i've made. my code is as below Code: class main extends Controller So my question is do i need to write an index funtion instead of page function. or how will my page functions get called when my user access following url Code: http://server.com/index.php
[eluser]Ivar89[/eluser]
I guess you could make your default_controller Code: $route['default_controller'] = "main/page";
|
Welcome Guest, Not a member yet? Register Sign In |