.htaccess添加Header set Cache-Control报错500

时间:2020-12-06 21:16:17

在优化网站开启站点的图片缓存时,需要在.htaccess文件中加入:

#文件缓存时间配置10分钟
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css)$">
Header set Cache-Control "max-age=600"
</FilesMatch>

但是一打开网页就报错了,如下:

  Internal Server Error

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

    Please contact the server administrator, webmaster@dummy-host.example.com 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.

嗯哼,后来想一下,估计是http.cofig配置的问题

LoadModule headers_module modules/mod_headers.so

取消#注释,重启Apache,就OK了