CodeIgniter Routing Folder Error

后端 未结 2 1939
余生分开走
余生分开走 2020-12-18 08:34

I have the CodeIgniter controller file, placed in here

controllers/public/Pubweb.php

and I want to set that file as my default controller,

2条回答
  •  别那么骄傲
    2020-12-18 09:14

    You can create a new file in the main controllers folder for routing purpose. for example, I have a directory structure like 'controllers/coming/Commingsoon.php'. if I want to run Commingsoon as my default controller so i will do this:

    create new file in controllers folder: Main_controller.php:

    class Main_controller extends CI_Controller{
        public function __construct(){
            parent:: __construct();
        }
    
        public function index(){    
            redirect('comming'); 
        }
    } 
    

    and in routes.php file:

    $route['default_controller'] = 'main_controller';
    
    $route['comming'] = 'comming/commingsoon/index';
    

    hope this will help...

提交回复
热议问题