kohana 3.3中的URL,index.php的问题

时间:2015-03-28 01:58:17

标签: php .htaccess kohana

我是kohana的新手,有些日子我现在无法使用index.php在控制器中进行操作。我总是收到错误“在服务器上找不到请求的网址” 下面是我的.htaccess文件

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /njorku.com/

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

这是我的控制器类

<?php defined ('SYSPATH') or die('No direct script access');

class Controller_Ask extends Controller {

    public function action_index (){
        $quests = ORM::factory('asknjorku_question')->order_by('question_id','desc')->find_all();   
        $view = View::factory('/en/asknjorku/index')->bind('quests',$quests);
        $this->request->response = $view;
    }

}
?>

当我去http://localhost/njorku.com/index.php/ask/index它有效但是  http://localhost/njorku.com/ask/index无法工作

为什么会这样,请帮帮我?

1 个答案:

答案 0 :(得分:0)

除了.htaccess,您可能需要修改bootstrap.php文件,特别是Kohana::init()来电:

Kohana::init(array(
    'base_url'   => '/njorku.com/',
    'index_file' => FALSE,
));