2009-12-03 125 views
2

我需要专家的帮助。混合两个文件htaccess

我试图将两种文件的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 

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

非常感谢你和原谅我的英语

维拉

+0

找到一个解决办法?如果你仍然有问题,请看我的答案,这可能是因为Apache2中缺少一个模块。 – 2009-12-10 23:16:49

回答

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

我试图在文件和文件中插入它,但没有工作: Header set Cache-Control“max-年龄= 2592000" 头设置的Cache-Control “最大年龄= 604800” 维拉 – Vera 2009-12-04 15:04:06

+0

我已经更新了我的文章因为我发现这是因为Apache2中缺少头文件模块(至少在我的安装中)。 – 2009-12-07 21:48:31

+0

Sune 谢谢你的回答,我在度假,没有看到你的答案。 找到的解决方案是使用mod_deflate和FilesMatch – Vera 2010-01-11 11:20:02