fengmo1984 发表于 2011-3-28 12:01:58

路由问题求助`

本帖最后由 fengmo1984 于 2011-3-28 12:32 编辑

今天第一天接触CI看了一下路由的文档,按上面的写了一下~
在application/config/routes.php里加入了
$route['default_controller'] = "welcome";
$route['404_override'] = '';
//自己加的
$route['hello'] = "hello/show";

在controllers里加入了hello.php
代码如下:
class Hello extends CI_Controller {
        function Hello(){
                    parent::Controller();
        }

        public function index()
        {       
                $this->load->view('hello_page');
        }
       
}

在views里放了一个hello_page.php文件
内容简单:就写了hello word

为什么我用http://localhost/ci/hello 进去page not found!

是不这么写咩~
请教高手指教一下路径的写法知识~

Hex 发表于 2011-3-28 12:21:32

你的控制器还是 Welcome 啊?请根据手册,按规定编写控制器。

fengmo1984 发表于 2011-3-28 12:28:33

这个错误已经改了~~还是不行~

huboo82 发表于 2011-3-28 13:44:28

如果是2.0版的CI:

class Hello extends CI_Controller {
      function __construct(){
                  parent::__construct();
          }

      public function index()
      {      
                $this->load->view('hello_page');
      }


      public function show()
       {
            $this->load->view('hello_page');
       }
}

huboo82 发表于 2011-3-28 13:46:36

$route['目的路由'] = "原始/路由";
页: [1]
查看完整版本: 路由问题求助`