Search code examples
.htaccesscachingerror-handling

FilesMatch results in Internal Server Error


I added the code below to my .htaccess file to enable caching files for 3 days. After that my website wasn't available anymore and I got a message displayed that told me it's an Internal Server Error

The code:

 # 3 DAYS 
    <FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$"> Header set Cache-Control "max-age=259200, proxy-revalidate" </FilesMatch>

The message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

What is wrong with the FilesMatch or what else could cause the Internal Server Error? Thanks


Solution

  • It has to be on multiple lines, not all in a single line. This one works fine for me:

    <FilesMatch "\.(html|css|js|gif|jpg|jpeg|png|ico|swf)$">
        Header set Cache-Control "max-age=259200, proxy-revalidate"
    </FilesMatch>