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

  • Posted April 17, 2014

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 ?


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

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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?

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/ 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?

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?

I think u delete .htpasswd file <br> <br>

Take a look at <a href=“”></a>. <br> <br>You need to edit your virtualhost config and set <code>AllowOverride</code> to <code>All</code>.