Adrian Covaci
Adrian Covaci

Reputation: 103

Apache modules required to work with FilesMatch and Headers in .htaccess

I try to figure out a web application installed on localhost. I'm using wampserver 2.5 on a 64 bits Windows machine.

This block from the .htaccess file generates a 500 Internal Server Error

<IfModule mod_headers.c>
    FileETag MTime Size
    ExpiresActive On
    ExpiresDefault "access plus 30 minutes"
    Header set X-UA-Compatible "IE=edge"
    Header set X-Powered-By "ADRIAN COVACI - All Rights Reserved, PhP, Javascript, Ajax, JQuery"
    Header set Retry-After "120"

    #---expire images after 240 minutes in the client's cache------------------------------
    <FilesMatch ".(jpg|jpeg|gif|png|ico|woff|ttf|eot|otf|svg)$">
        ExpiresDefault "access plus 240 minutes"
        Header set Cache-Control "private"
    </filesMatch>

    #---expire css,js,html after 30 minutes in the client's cache-------------------------
    <FilesMatch ".(css|js)$">
        ExpiresDefault "access plus 30 minutes"
        Header set Cache-Control "private"
    </filesMatch>

    #---expire media files after 30 minutes in the client's cache-------------------------
    <FilesMatch ".(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
        ExpiresDefault "access plus 30 minutes"
        Header append Cache-Control "private"
    </FilesMatch>

    #---Force no caching for dynamic files---------------------------------------------
    <FilesMatch ".(php|cgi|htm|html)$">
        ExpiresActive Off
        Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
        Header set Pragma "no-cache"
    </FilesMatch>
</IfModule>

I don't know exactly what modules I have to turn on in the apache to make this works. Do you have some suggest?

After a couple of tests I found that the problem comes from ExpiresActive On and ExpiresActive On ... I don't know exactly how to handle this issue.

Upvotes: 3

Views: 2739

Answers (1)

Adrian Covaci
Adrian Covaci

Reputation: 103

I found the solution. ExpiresActive requires mod_expires to be on in the apache modules.

.htaccess 500 internal server error when set ExpiresActive

Upvotes: 2

Related Questions