Can’t get mod_expires to work on an EC2 Bitnami image

I’ve been unable to successfully get a client’s website to set expires. They’re running a bitnami cloud image on an EC2 instance.
Things I’ve tried:

    1. Loading the mod_expires module into apache with httpd.conf
      Specifically: “LoadModule expires_module modules/mod_expires.so”
    2. Using the wordpress plugin “W3 Total Cache”
      This plugin fails to detect the mod_expires module, but I am fairly sure that it ships with bitnami
    3. editing .htaccess directly
      Using ExpiresActive On ExpiresDefault “access plus 90 days”
    4. The tutorial here: http://www.theitbaby.com/wordpress/2013/10/14/optimizing-bitnami-for-pagespeed-insights-and-gtmetrix/

Strangely, apache complains when I use the code provided in the above mentioned tutorial gives me an error saying that ExpiresByType takes two arguments. When I change “access plus 9 months” to “A2592000” it seems to go back to working.

Read More

I’m out of options left to try and low on hope. Any ideas?

Solution:
1) configure .htaccess to use mod_expires [as can be seen here]http://www.inmotionhosting.com/support/website/htaccess/apache-module-mod-expires)
2) change httpd-app.conf to use AllowOverride All

Related posts

Leave a Reply

2 comments

  1. Setting “AllowOverride All” presents a security issue and should be avoided. I solved the same problem by using “seconds code” syntax, although I can’t explain why the alternative syntax did not work.

    Use A7776000 instead of “access plus 3 months”

    Example:

    ExpiresActive On
    ExpiresDefault A7776000

  2. Your problem is probably because .htaccess is disabled in bitnami build by default (see Understand .htaccess on bitnami). You may check whether the AllowOverride option is set to None in your httpd.conf. If it is, then .htaccess is disabled. Therefore, you need to move the content in .htacess to <your-wordpress-folder>/conf/htaccess.conf. Don’t forget to restart apache.