2012-10-29 43 views
1

我使用Kohana 3.2框架,我已將標準.htaccess文件放在應用程序的同一文件夾中。Kohana在.htaccess中重寫URL顯示文件未找到消息

我的.htaccess文件是

# Turn on URL rewriting 
RewriteEngine On 

# Installation directory 
RewriteBase /mysite/ 

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

我試圖改變拉斯線

RewriteRule ^(.*)$ /index.php/$0 
RewriteRule ^(.*)$ /index.php/$0 [PT,L] 
RewriteRule ^(.*)$ /index.php/$0 [PT,L,QSA] 
RewriteRule .* /index.php/$0 [PT] - [PT,L] - [PT,L,QSA] 

但它仍然顯示

未找到

請求在此ser上未找到URL /index.php/login版本。

The complete path of the app is /var/www/es/ec/mysite 

The complete working URL is http://10.0.0.1/ec/mysite/index.php/login 

The complete NOT working URL is http://10.0.0.1/ec/mysite/login 

也...

Running in Apache 2.2.3 over CentOS 5 

任何想法???

回答

0

你可以試試我的Kohana .htaccess文件

# Set environment 
SetEnv KOHANA_ENV "development" 

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

我用Kohana的3.2,也。這個重寫往往適用於我的大部分項目。

讓我知道它是如何工作的!

+0

嗨Brent Lingle,我嘗試你的.htaccess,但它仍然顯示「未找到 - 在此服務器上找不到請求的URL /index.php」。信息。對於我在Centos5服務器上使用Apache 2.2.3的記錄。 – GusCh

0

在你的bootstrap.php中的Kohana :: init已設置 'index_file'=> '',

+0

感謝Meliborn,仍然收到相同的訊息。還嘗試'index_file'=>'index.php',並使用默認參數'index_file'=> FALSE。任何想法?? – GusCh

+0

'base_url'=> dirname($ _ SERVER ['SCRIPT_NAME']) – Meliborn

1

我明白了!

下面是當應用程序位於其他文件夾內時它如何完成。

The complete path of the app is /var/www/es/ec/mysite 

The complete working URL is http://10.0.0.1/ec/mysite/index.php/login 

The complete NOT working URL was http://10.0.0.1/ec/mysite/login 

在/var/www/es/ec/mysite/application/bootstrap.php Kohana的初始化::保持這樣

Kohana::init(array(
    'base_url' => '/ec/mysite/', 
    'index_file' => FALSE, 
    'charset' => 'ISO-8859-1', 
)); 

而且這樣

# 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 .* /ec/mysite/index.php/$0 
的的.htaccess

希望這可以幫助別人!

乾杯!