2009-12-03 119 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