When I add mod_expires rules in .htaccess file, I am getting 500 server error

April 17, 2014 12k views
I have installed WordPress from one click installation. I have enabled mod_expires and mod_headers. Now when I am trying to add mod_expires rule in .htaccess file, I am getting 500 server error. error.log file says: /var/www/.htaccess: ExpiresActive not allowed here What should I do now ?
6 Answers
Take a look at http://serverfault.com/a/98159.

You need to edit your virtualhost config and set AllowOverride to All.
I think u delete .htpasswd file

I am having the same problems when trying to add mod_expires to my .htaccess file.

I used the one click install so I don’t appear to have a Virtual Host set up for my domain. It just sits in /var/www and there is no virtual host config file. Am I safe to follow these instructions to set one up or do I need to do something differently? https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts

by Etel Sverdlov
This tutorial shows you how to set up a new directory, how to grant the correct permissions, how to add content to a new page, how to turn on virtual hosting, and how to, if needed, set up local hosts. Virtual Hosts are used to run more than one domain off of a single IP address and allows you to run multiple sites off of a single DigitalOcean droplet. This tutorial describes how to set up virtual hosts with Apache.
  • What application image are you using? The virtualhost should be in /etc/apache2/sites-enabled.

  • Is this on the WordPress one-click? If so, the configuration is in:


Thanks for this guys. I remembered that I had a subdomain with a .conf so I tested it there. I still got a 500 database error when I tried to add the code to that .htaccess file - and worse still I forgot to remove the AllowOverride line before I went to bed and my server crashed out in the night.

When I tried to restart Apache to it said:

AH00526: Syntax error on line 14 of /etc/apache2/sites-enabled/static.supermommyclub.com.conf:
AllowOverride not allowed here
Action ‘configtest’ failed.

I went in and removed the line and my site came back online.

I’m at a loss as to why I can’t get the mod_headers to work and also need to know why I am getting so many intermittent unable to connect to database errors. I am having far too much downtime.

Any hints onto what I can be checking for?

  • Can you pastebin the contents of /etc/apache2/sites-enabled/static.supermommyclub.com.conf? The AllowOverride All line should be somewhere between <Directory /var/www/> and </Directory>.

Kamal I was missing the <Directory /var/www/> and </Directory> part of the code. I now have it working on my subdomain.

I don’t have /etc/apache2/apache.conf but I do have /etc/apache2/apache2.conf is that the file I need to use for the main domain?

  • Yes, the correct path is /etc/apache2/apache2.conf. The main domain’s config is most likely in /etc/apache2/sites-enabled but in a different file. You can list the directories contents by running

    ls /etc/apache2/sites-enabled

    or simply ls after cd-ing into it.

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!