.htaccesscache-controlapache2.4mod-expires

htaccess ExpiresDefault conditional


I have in my Apache 2.4's .htaccess the following:

ExpiresActive On
ExpiresDefault "access plus 1 month"

However, pages that start with today_ (files actually not present on the server) should not be cached. How would you write that condition?


Solution

  • If you are using Apache 2.4 and you should be :) You can simply use a condition statement. I think these are overlooked a lot. I would approach it this way.

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