【问题标题】:mix two files htaccess混合两个文件 htaccess
【发布时间】:2010-11-05 11:51:43
【问题描述】:

我需要专家的帮助。

我正在尝试混合两个文件 htaccess

第一个:

<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A300
</IfModule>

第二个:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>

第一个文件被插件 wp-supercache (worpress) 使用

我想要那个

image files Cache-Control = 2592000  
files as css e js Cache-Control = 604800  
files htm had Cache-Control = 43200  

但它不想失去插件的功能,因此我寻求帮助。

非常感谢,请原谅我的英语

维拉

【问题讨论】:

  • 找到解决方案了吗?如果您仍然遇到问题,请查看我的回答,这可能是因为 Apache2 中缺少模块。

标签: wordpress .htaccess


【解决方案1】:

您似乎缺少 Apache 中的 headers 模块(我假设下面是 Apache2,但语法应该几乎相似)。这适用于我的机器(没有加载标题模块):

<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Cache-Control 'max-age=300, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A300
</IfModule>

<IfModule mod_headers.c>
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>    
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>
</IfModule>

在 Apache2 中启用 headers 模块:

a2endmod headers
apache2ctl restart

【讨论】:

  • 我试图在文件和文件中插入这个但没有成功: Header set Cache-控制 "max-age=2592000" 标头集 Cache-Control "max-age=604800" Vera
  • 我已经更新了我的帖子,因为我发现这是因为 Apache2 中缺少 headers 模块(至少在我的安装中)。
  • Sune 感谢您的回答,我正在度假,没有阅读您的回答。找到的解决方案是将 mod_deflate 与 FilesMatch 一起使用
猜你喜欢
  • 1970-01-01
  • 2012-03-02
  • 2017-11-29
  • 1970-01-01
  • 1970-01-01
  • 2022-12-17
  • 1970-01-01
  • 2012-08-03
  • 1970-01-01
相关资源
最近更新 更多