Index.php Apache 2.2 到 2.4 更新后重写失败

Index.php rewrite fails after Apache 2.2 to 2.4 update

我的 Kohana 3.3 项目的 .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/[=11=] [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/[=11=] [PT]

根据 Eric 的建议,我已将 htaccess 更新为以下内容:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed
<Files ".*">
  Require all denied
</Files>

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

我更新了虚拟主机以包括:

<Directory /srv/www/example.com/public_html/>
    Require all granted
</Directory>

我是不是漏掉了什么?

修改后的 htaccess

# Protect hidden files from being viewed
<Files .*>
  Require all granted
</Files>

并将 AllowOverride All 添加到虚拟主机配置。

<Directory /var/www/example.com/public_html/>
    Require all granted
    AllowOverride All
</Directory>