Search code examples
phpapache.htaccesskohana

Index.php rewrite fails after Apache 2.2 to 2.4 update


My .htaccess file for a Kohana 3.3 project is:

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

Following Eric's advice I have updated the htaccess to the following:

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

I updated the Virtual Host to include:

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

Did I miss something else?


Solution

  • Modified htaccess

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

    and added AllowOverride All to virtualhost config.

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