Codeigniter making sub-directory controllers work

前端 未结 1 628
既然无缘
既然无缘 2020-12-18 03:14

I\'m having trouble making the page load the controller I want it too.

For example I want my site to load as localhost/sitename/catergory1/catergory2 where catergory

相关标签:
1条回答
  • 2020-12-18 03:45

    You have a typo in category1 btw.

    If I follow correctly you have this structure:

    \ controllers
     - home.php
     \ category1 \
      - cat1.php
    

    If so, you confused yourself with your route:

    $route['category1 '] = 'category1/cat1/index';
    

    Need to define the method index, this is based on your 'cat1.php' file being:

    class Cat1 extends CI_Controller{
       function index() {
          $this->load->view('cat1');
       }
    }
    

    I wrote about this, as people usually get confused with routes in CI:
    http://blog.biernacki.ca/2011/12/codeigniter-uri-routing-issue-with-controller-folders/

    0 讨论(0)
提交回复
热议问题