Php 如何在codeigniter w/0db中进行动态路由

Php 如何在codeigniter w/0db中进行动态路由,php,codeigniter,routing,Php,Codeigniter,Routing,正在尝试将页面路由为website.com/'schoolname'。如果有同名的控制器,它将通过它。。否则它将检查数据库中是否有这样的学名,如果有,它将转到其配置文件页面。。如果没有mattches,它将返回404页 代码 路线 $wind = array("app.php","assignment.php","backup.php","book.php","bulkimport.php","category.php","classes.php","conversation.php"

正在尝试将页面路由为website.com/'schoolname'。如果有同名的控制器,它将通过它。。否则它将检查数据库中是否有这样的学名,如果有,它将转到其配置文件页面。。如果没有mattches,它将返回404页

代码

路线

 $wind =     array("app.php","assignment.php","backup.php","book.php","bulkimport.php","category.php","classes.php","conversation.php","dashboard.php","eattendance.php","event.php","exam.php","examschedule.php","exceptionpage.php","expense.php","feetypes.php","grade.php","hmember.php","holiday.php", "hostel.php","index.html" , "install.php","invoice.php" , "issue.php" ,"language.php", "lmember.php" , "mailandsms.php" ,"mailandsmstemplate.php", "mark.php" , "markpercentage.php", "media.php", "menu.php", "migration.php" ,"notice.php" , "parents.php", "paymenthistory.php" , "paymentsettings.php" , "permission.php", "profile.php", "promotion.php" , "report.php" , "reset.php", "resetpassword.php" , "routine.php" , "sattendance.php", "school.php" ,"schoolyear.php" ,"section.php", "setting.php" , "signin.php" , "signup.php" , "smssettings.php" ,"student.php" , "subject.php" , "syllabus.php" , "systemadmin.php", "tattendance.php", "teacher.php" ,"tmember.php" ,"transport.php" , "update.php" , "user.php" , "usertype.php" , "visitorinfo.php" );



 foreach ($wind as $win)
 {
 $controllers[] =  $win;
  }

   $id = $this->uri->segment(1);


   if (in_array($id.'.php', $controllers)){


   $route[$id] = $id;


  }else{

 $route[$id] = 'school/index/'.$id;

}
控制器

    public function index($id = null)
{

   $a = $this->systemadmin_m->get_fnall($id);




  if($a != null){

    $this->load->view('front/header');
     $this->load->view('front/includes');
    $this->load->view('front/sindex');
    $this->load->view('front/footer');

}else{


       $this->load->view('errors/notfound');
}


}

使用真正的路由组件!尝试symfony或zend framework路由器,可使用composer安装

对不起,伙计们,这是foreach中的一个错误,我从某处复制了那个部分。它工作得很好。暂时修复了它。。我要试试那些