2014-01-05 83 views
0

。 大家好,Kohana 404錯誤:請求的網址未找到

我正在爲一個學校項目的網站工作。 最近我在Biberbit.com購買了我自己的webspace,並想上傳我的網站。 當我把它上傳我看到屏幕上出現以下錯誤:

Kohana_HTTP_Exception [ 404 ]: The requested URL/was not found on this server. 

我的項目使用Kohana的框架版本3.3.1 我已經有.htaccess文件和文件名/目錄名全部小寫。 我使用的是默認路由:

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

原本我以爲這可能是在bootstrap.php中文件DEFAULT_URL所以我改變了這些行這樣:

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

我已經在多個網站上尋找解決方案,但無法找到適合我的解決方案。 任何人都可以想到我可能會錯過的東西嗎? 我也在爲我的鏈接使用URL::site(),所以我不認爲這是造成它。

您可以檢查在http://www.biberbit.com

編輯錯誤和/或網站: 的.htaccess的要求

# Turn on URL rewriting 
RewriteEngine On 

# Installation directory 
RewriteBase/

# Protect hidden files from being viewed 
<Files .*> 
    Order Deny,Allow 
    Deny From All 
</Files> 

# 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] 
+0

你可以添加.htaccess嗎? – kero

+0

@kingkero我想我在安裝目錄的.htaccess中發現了什麼問題。 – user1433479

+0

當你改變'RewriteBase'時它會工作嗎? – kero

回答

0

base_url設置錯了,應該是空的(因爲你是在web根目錄)。另外,根據您是否有Linux,文件名不得爲全部小寫,但是您在代碼中使用它們。因此Welcome.php而不是welcome.php爲默認控制器。

+0

奇怪的是,我最初嘗試了空的base_url,所以它必須是文件名。我會檢查它並將結果返回給您。文件url中的名稱總是小寫,但在類名稱中,它是Controller_Welcome for welcome.php。 – user1433479

+0

我已經改變了文件名以反映類名並清空了base_url字符串,但它仍然給我404。 – user1433479

+0

對不起,但有了正確的文件名並正確設置了'base_url',它應該可以工作。 – kero

0

Kohana_HTTP_Exception [ 404 ]: The requested URL/was not found on this server.當Kohana無法找到相應的操作方法來處理請求時,通常會拋出異常。

確保你有Controller_Welcome類和action_index方法在裏面。

此外,您可以檢查您的異常追溯,並找到究竟是什麼導致了異常。很可能你會在if(!method_exists(...))塊中看到SYSPATH/classes/Kohana/Controller.php文件中的Exeption。