【问题标题】:htaccess ExpiresDefault conditionalhtaccess ExpiresDefault 条件
【发布时间】:2016-12-17 15:08:22
【问题描述】:

我在 Apache 2.4 的 .htaccess 中有以下内容:

ExpiresActive On
ExpiresDefault "access plus 1 month"

但是,不应缓存以today_ 开头的页面(文件实际上 存在于服务器上)。你会怎么写那个条件?

【问题讨论】:

    标签: .htaccess cache-control apache2.4 mod-expires


    【解决方案1】:

    如果您使用的是 Apache 2.4,那么您应该是 :) 您可以简单地使用条件语句。我认为这些都被忽略了很多。我会这样处理它。

    #if URL contains today_ turn it off
    <If "%{REQUEST_URI} =~ /today_/">
        ExpiresActive Off
    </If>
    <Else>
        ExpiresActive On
        ExpiresDefault "access plus 1 month"
    </Else>
    

    【讨论】:

    • 你有什么版本的apache?有什么事情发生
    • 等待.. 由于某种原因,以下正则表达式匹配得不好:&lt;If "%{REQUEST_URI} =~ /(today_|hoy_|hoje_)/"&gt;
    • 我认为它不匹配,因为文件系统中不存在该文件(mod_rewrite)
    猜你喜欢
    • 2011-12-17
    • 2017-12-13
    • 2014-12-18
    • 2013-08-27
    • 2012-06-28
    • 2011-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多