Apache/2.4.6 update causes 404s

apache-2.4mod-rewrite

I'm running a ec2 ubuntu instance, I decided to update my PHP today to 5.5.7, unfortunately it triggered apache to update as well, which has caused me many errors, the biggest one is my rewrite rules are no longer being hit and I believe its something todo with .conf changes.

My site conf (yes my front and backend site share the same .conf, somewhat lazy but was convenient.

<VirtualHost *:80>
  DocumentRoot /var/www/hivetracking-front/checkout/hive-tracking/public/
  ServerName hivetracking.com
  ServerAlias www.hivetracking.com
  SetEnv _ENV production

        <Directory />
                DirectoryIndex index.phtml
                RewriteEngine On
                LogLevel alert rewrite:trace6
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>


        ErrorLog /var/www/hivetracking-front/error.log


        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/www/hivetracking-front/access.log combined
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /var/www/hivetracking-back/checkout/hive-tracking-api/public
  ServerName api.hivetracking.com
  SetEnv _ENV production

        <Directory />
                DirectoryIndex index.php
                RewriteEngine On
                LogLevel alert rewrite:trace6
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>


        ErrorLog /var/www/hivetracking-back/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        CustomLog /var/www/hivetracking-back/access.log combined
</VirtualHost>

My .htaccess for the API:

RewriteEngine on
ServerSignature On
DirectoryIndex index.php
Options Indexes FollowSymLinks


<FilesMatch "\.(ico|pdf|flv)$">
    Header set Cache-Control "max-age=29030400, public" #1 YEAR
</FilesMatch>
<FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK
</FilesMatch>
<FilesMatch "\.(html|htm|php|js)$">
    Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS
</FilesMatch>


# system/session
RewriteRule ^([-A-Za-z0-9]+)/([-A-Za-z]+)$ index.php?__module=$1&__action=$2 [L,QSA]

# teams/something/123456
RewriteRule ([-A-Za-z0-9]+)/([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=$2&id=$3 [L,QSA]

# teams
RewriteRule ^([-A-Za-z0-9]+)$ index.php?__module=$1&__action=index [L,QSA]

# teams/123456
RewriteRule ([-A-Za-z0-9]+)/([0-9a-fA-F]{24}+)$ index.php?__module=$1&__action=index&id=$2 [L,QSA]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Going to http://api.mydomain.com/client results in a 404
Going to http://api.mydomain.com/index results in a 404
Going to http://api.mydomain.com/index.php loads the file

Any help greatly appreciated!


EDIT

I fixed this by removing these from the .htaccess

<FilesMatch "\.(ico|pdf|flv)$">
    Header set Cache-Control "max-age=29030400, public" #1 YEAR
</FilesMatch>
<FilesMatch "\.(xml|txt|css|jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=172800, proxy-revalidate" #1 WEEK
</FilesMatch>
<FilesMatch "\.(html|htm|php|js)$">
    Header set Cache-Control "max-age=60, private, proxy-revalidate" #2 DAYS
</FilesMatch>

I have no idea why it took me 8 hours of debugging to track this down but the errors weren't being logged.

Best Answer

Search your configuration files for all examples of AllowOverride. Likely something that has been added which is replacing the one in your config above.

Second, in your config for the VirtualHost, replace the Directory statement with your document root:

    <Directory /var/www/hivetracking-front/checkout/hive-tracking/public>
            DirectoryIndex index.php
            RewriteEngine On
            LogLevel alert rewrite:trace6
            Options Indexes FollowSymLinks
            AllowOverride All
    </Directory>

This will help assure something else is not overriding the AllowOverride Setting.

Related Topic