1

我正在使用 Kohana 3.2 框架,我已将标准 .htaccess 文件放在应用程序的同一文件夹中。

我的 .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]

我尝试将 las 线更改为

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]

但它仍然显示

未找到

在此服务器上找不到请求的 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

任何想法???

4

3 回答 3

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::init 保持这样

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

像这样的 .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 .* /ec/mysite/index.php/$0

希望这对其他人有帮助!

干杯!

于 2012-10-30T13:49:16.003 回答
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。这种重写往往适用于我的大多数项目。

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

于 2012-10-29T18:15:58.220 回答
0

在 Kohana::init 内的 bootstrap.php 中设置 'index_file' => '',

于 2012-10-29T19:37:42.957 回答