0

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.

4
  • Have you checked the AllowOverride settings in the main Apache file to see if they may be causing an issue. Jan 3, 2014 at 14:22
  • Setting it None or All makes no difference unfortunately
    – azz0r
    Jan 3, 2014 at 14:27
  • Try replacing the directory line in your config with the full path to your document root: Directory var/www/hivetracking-front/checkout/hive-tracking/public/ Since you have / there could be a more specific match changing your settings. Also are you sure your htaccess is even being processed? Try putting an error in the file and see if you get a 500 error. Jan 3, 2014 at 14:35
  • Please search all apache config files for AllowOverrideList and AllowOverride. If you set AllowOverride to none htaccess is ignored. Jan 3, 2014 at 14:38

1 Answer 1

1

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.

4
  • I just made an error in my .htaccess and it made no diffence, so you are correct, the .htaccess isn't being read. What would I set AllowOverrideList to for it to read the .htaccess?
    – azz0r
    Jan 3, 2014 at 14:46
  • I've updated my answer. I suspect you have conflicting override statements. In your config you use Directory /. If in the new config there is Directory /var/www/html with a AllowOverride None it will replace your directive. So try my answer above. Jan 3, 2014 at 14:56
  • with the following: pastebin.com/KVdj9djm, theres no change
    – azz0r
    Jan 3, 2014 at 15:15
  • With the following though: pastebin.com/V9pXTUY1, I get this in the error log: [api.hivetracking.com/sid#7f784cba9158][rid#7f784cae50a0/initial] [perdir /] pass through /var/www/hivetracking-back/checkout/hive-tracking-api/public/client
    – azz0r
    Jan 3, 2014 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .