1
ExpiresActive On
ExpiresDefault "access plus 1 day"
 [...]
RewriteRule .* index.php [L]

这是我对mod_expires加上相关的RewriteRule的设置。他们完美地工作!但我有一个特定的 URL,不应被缓存。正则表达式将是^/?nocache/. 现在该目录 ( /nocache/) 甚至在物理上都不存在;对它的请求 - 对于所有其他目录 - 由“index.php”处理。

我的第一个想法是<LocationMatch>在它周围添加一个,但是文档说,在“.htaccess”上下文中是不允许的。A<FilesMatch>将被允许,但需要文件物理存在,我认为((真的?))。

有任何想法吗?

4

1 回答 1

1

您可以RewriteRule在 .htaccess 中使用指令:

ExpiresActive On
ExpiresDefault "access plus 1 day"
 [...]

RewriteEngine On
RewriteRule ^nocache - [E=NOCACHE:1]

SetEnvIf REDIRECT_NOCACHE 1 NOCACHE=1

# DO NOT cache /nocache/ URIs
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform" env=NOCACHE
Header set Pragma "no-cache" env=NOCACHE
于 2014-08-14T08:46:54.487 回答