having problem creating a default controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: having problem creating a default controller (/showthread.php?tid=31293) |
having problem creating a default controller - El Forum - 06-13-2010 [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 ! having problem creating a default controller - El Forum - 06-14-2010 [eluser]cahva[/eluser] So you main controller is in here for sure?: system/application/controllers/main.php Post your main controller code. having problem creating a default controller - El Forum - 06-14-2010 [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 having problem creating a default controller - El Forum - 06-14-2010 [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 having problem creating a default controller - El Forum - 06-14-2010 [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'); having problem creating a default controller - El Forum - 06-14-2010 [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 having problem creating a default controller - El Forum - 06-14-2010 [eluser]Ivar89[/eluser] I guess you could make your default_controller Code: $route['default_controller'] = "main/page"; having problem creating a default controller - El Forum - 06-17-2010 [eluser]UdayD[/eluser] thanks its done in that way u showed |