在.htaccess中使用FilesMatch和Headers所需的Apache模块

时间:2014-10-30 17:07:24

标签: apache .htaccess

我试图找出安装在localhost上的Web应用程序。我在64位Windows机器上使用wampserver 2.5。

.htaccess文件中的此块会生成500内部服务器错误

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

我不确切知道在apache中打开哪些模块才能使其正常工作。 你有什么建议吗?

经过几次测试后,我发现问题来自ExpiresActive OnExpiresActive On ...我不确切知道如何处理这个问题。

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。 ExpiresActive需要在apache模块中启用mod_expires

.htaccess 500 internal server error when set ExpiresActive