kohana还是路由route问题

来源:互联网 发布:java编程大赛题目 编辑:程序博客网 时间:2024/06/06 12:51
不能访问:http://localhost/index.php/manager/a/index
class Controller_A extends Controller {
   public function action_index(){
       echo 'A';
   }
}


可以访问:http://localhost/index.php/manager/a/a/index
class Controller_A_A extends Controller {
   public function action_index(){
       echo 'A/A';
   }  
}




init.php
Route::set('manager', 'manager(/<controller>(/<action>(/<param>)))' ,array('param'=>'.*'))
->defaults(array(
'controller' => 'manager',
'action' => 'index',
));


Route::set('manager', 'manager(/<directory>(/<controller>(/<action>(/<param>))))',array('param'=>'.*'))
->defaults(array(
'controller' => 'manager',
'action' => 'index',
'directory' => '',
));






kohana还是路由route问题
无法访问url,找不到地址,于是“从简化”,即用上面的例子新建modules名,如manager文件夹,在里面新建文件a.php如上,用于测试
init.php里主要配置路由,然后一步步调试
第一种是没有文件夹的控制器文件,即controller/a.php
第二种是:controller/a/a.php


奇怪的是第2种可以访问,然后把init.php中第2个路由删除,第1种url还是不能访问,但过会后,不断的刷新,竟然可以正常访问了。


于是:判定route是正确的,错误原因可能是浏览器缓存造成的!!但调试方法可以用上面的。


能够正确打开url后,自动跳转到http://localhost/index.php/auth
可能是没有权限或未登录
bo中先加载modules,最后加载了一个全局通吃路由,之前有提过:
Route::set('default', '(<controller>(/<action>(/<params>)))' , array('params' => '.*?'))
    ->defaults(array(
        'controller' => 'auth',
        'action'     => 'index',
    ));


即默认什么都没有的话,跳转到auth/index
http://localhost/index.php/auth/index 可以正常访问。


但是在modules/auth中并没有找到index方法。。。。这是为什么呢?
其实auth/index是在application中了。。。。。。。憋孙。




于是进入登录页面。。。
application/class/controller/auth/login()
 $log_chk = Auth::instance()->login($this->request->post('email'), $this->request->post('password'), $remember);


还是调用的modules/auth/kohana/auth/login();
public function login($email, $password, $remember = FALSE)
{
if (empty($password))
return FALSE;


if (is_string($password))
{
// Create a hashed password
$password = $this->hash($password);
//echo $password;//直接输出hash的密码,存到数据库中,即可。
//exit;
}


return $this->_login($email, $password, $remember);
}

原创粉丝点击