2013-06-28 58 views
0

我最近將我的應用程序從Windows本地主機遷移到Linux主機。Kohana 3部署控制器問題

我的問題是,我無法訪問控制器,我總是不斷收到消息:找不到文件(從Web服務器)

這是奇怪,因爲相同的代碼庫正在我本地主機。

bootstrap.php中:

Route::set('default', '(<controller>(/<action>(/<id>)(/<param1>)(/<param2>)))') 
    ->defaults(array(
     'controller' => 'user', 
     'action'  => 'index', 
        'param1' =>'', 
        'param2' =>'', 
    )); 

的.htaccess:

# Turn on URL rewriting 
RewriteEngine On 

# Installation directory 
RewriteBase/


# Protect application and system files from being viewed 
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [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] 

這裏發生的奇怪的事情是,如果我去: www.myapp.com/那麼默認控制器執行並找到用戶/索引功能。

但是,如果我手動將它寫爲www.myapp.com/user/index我不斷收到File not found消息。

我試着用小寫重命名控制器文件,所以我猜這不是問題,除此之外,如果這將是問題,默認路由不會在第一個地方找到它,對嗎?

舉例來說,如果我寫的默認路由:

Route::set('default', '(<controller>(/<action>(/<id>)(/<param1>)(/<param2>)))') 
    ->defaults(array(
     'controller' => 'user', 
     'action'  => 'login', 
        'param1' =>'', 
        'param2' =>'', 
    )); 

我accesss www.myapp.com,它會加載用戶的功能。我無法弄清楚這裏有什麼問題,爲什麼當我寫myapp.com/user/login時說沒有找到文件,但是如果我把它作爲默認路由,它會打開它。

回答

0

你是否在bootstrap.php中設置了base_url?如果沒有,你應該設置BASE_URL your_project_name/

如果是的話,你應該設置RewriteBase/your_project_name /也是你的.htaccess

0

我發現在與此相關的另一個線程解決方案。你需要這個代碼塊添加到的.htaccess:

<IfModule mod_rewrite.c>  
     RewriteEngine On 
     RewriteBase/
     RewriteRule ^index\.php$ - [L] 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule . /index.php [L] 
    </IfModule> 

希望它可以幫助別人!