sjbuysse sjbuysse - 1 year ago 65
Apache Configuration Question

.htaccess has no effect and doesn't send expires header

I added an

file to the website root folder

It looks like this

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

I tried adjusting the
option, as is recommended in a lot of places.
file looks like this

<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</VirtualHost *:80>

looks like this

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied

<Directory /usr/share>
AllowOverride None
Require all granted

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

I'm fairly certain that the
file is just not working, because when I add random characters to the file (to try and break it and get a
HTTP response) it doesn't affect the website at all.
What could be causing this?

Answer Source

Expiry information is created and sent by the expires module. In accordance with that the .htaccesscorrectly checks for the existence of this module. If it is not loaded, no action is taken here.

Make sure that the module is loaded correctly, the currently most compatible way to do this is with a2enmod:

:~ $ a2enmod expires
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download