Routing problem on Live server - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: Routing problem on Live server (/showthread.php?tid=68914) |
Routing problem on Live server - Duk - 09-13-2017 My codeIgniter application only shows default controller on live server but runs just fine on local server, the default controller has a view method which displays login page as the first page but submit button wont submit upon providing login details my index.php page is set to production environment below are my config and route files . please help // Config.php $config['base_url'] = 'http://phpstack-114475326109.cloudwaysapps.com/'; $config['index_page'] = 'index.php?'; $config['uri_protocol'] = 'REQUEST_URI'; //end config.php //routes.php $route['(:any)'] = 'pages/view/$1'; $route['default_controller'] = 'pages/view'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; //end config RE: Routing problem on Live server - InsiteFX - 09-13-2017 Read the Users Guide The default controller You can NOT use a directory as a part of this setting! RE: Routing problem on Live server - Duk - 09-14-2017 (09-13-2017, 08:24 AM)InsiteFX Wrote: Read the Users Guide I have looked at the User Guide , still i dont understand what you mean I can not use a directory as part of the setting RE: Routing problem on Live server - InsiteFX - 09-14-2017 You can not use a directory in the default controller: PHP Code: $route['default_controller'] = 'pages/view'; Your view is in a directory called pages. I can not send you any messages because you have Private messages disabled! RE: Routing problem on Live server - Duk - 09-14-2017 (09-14-2017, 08:40 AM)InsiteFX Wrote: You can not use a directory in the default controller: Hi Insite i just enabled my Private message please do reply . I have a controller page called Pages.php with a class called Pages and a method view Thats why I though the routing for the default controller should then be $route['default_controller'] = 'pages/view'; class Pages extends MY_Controller { if (!file_exists(APPPATH.'views/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } public function view($page = 'login') { // rest of code } } RE: Routing problem on Live server - ciadvantage - 09-15-2017 Code: <? RE: Routing problem on Live server - Duk - 09-19-2017 (09-15-2017, 11:26 AM)ciadvantage Wrote: Thank you for the input, i tried to add the constructor like you said, check below, but still though the login in page is displayed as the fist page but submit button wont submit upon giving my login in details class Pages extends MY_Controller { public function __construct() { parent::__construct(); $this->load->library('session'); } public function index($page = 'login') { if (!file_exists(APPPATH.'views/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); } $data['title'] = ucfirst($page); // Capitalize the first letter f($page == 'dashboard') { $this->load->model('model_student'); $this->load->model('model_teacher'); $this->load->model('model_classes'); $this->load->model('model_marksheet'); $data['countTotalStudent'] = $this->model_student->countTotalStudent(); $data['countTotalTeacher'] = $this->model_teacher->countTotalTeacher(); $data['countTotalClasses'] = $this->model_classes->countTotalClass(); $data['countTotalMarksheet'] = $this->model_marksheet->countTotalMarksheet(); } if($page == 'login') { if($this->session->userdata('logged_in') === true) { redirect('../dashboard'); } $this->load->view($page, $data); } } } Code: ... |