2014-06-11 81 views
0

因此,由於我在我的網站上託管我的博客在同一臺服務器上,我想我會創建一個別名,以便我可以拉入我的投資組合。.htaccess沒有緩存別名文件夾的圖像

Alias /port-images/ /the/real/location/wp-content/uploads/ 

在這兩個我的博客,我拉的圖像轉換成包含以下的.htaccess代碼的網站:

# caching static files 
<IfModule mod_headers.c> 
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|bmp|js|css|swf|woff|svg|ttf|otf|eot)(\.gz)?$"> 
Header unset Pragma 
Header unset ETag 
Header set Cache-Control "max-age=31556000, store, cache" 
Header unset Last-Modified 
Header set Connection keep-alive 
Header add X-PoweredBy "" 
</FilesMatch> 
</IfModule> 
FileETag None 
<IfModule mod_expires.c> 
ExpiresActive On 
ExpiresDefault "access plus 1 seconds" 
ExpiresByType text/html M31556000 
ExpiresByType image/gif M31556000 
ExpiresByType image/jpeg M31556000 
ExpiresByType image/png M31556000 
ExpiresByType text/css M31556000 
ExpiresByType text/javascript M31556000 
ExpiresByType application/javascript M31556000 
ExpiresByType application/x-javascript M31556000 
ExpiresByType text/xml M31556000 
ExpiresByType image/svg+xml M31556000 
ExpiresByType application/x-font-ttf M31556000 
ExpiresByType application/x-font-truetype M31556000 
ExpiresByType application/x-font-opentype M31556000 
ExpiresByType application/vnd.ms-fontobject M31556000 
ExpiresByType application/x-font-woff M31556000 
</IfModule> 

# For servers that support output compression, you should pick up a bit of 
# speed by un-commenting the following lines. 

php_flag zlib.output_compression On 
php_value zlib.output_compression_level 9 

雖然圖像就好拉,沒有這個緩存是流汗應用圖像被拉入。我甚至已經添加了這個相同的.htaccess到/the/real/location/wp-content/uploads/,沒有什麼區別。

我能做些什麼來確保這些.htaccess設置對位於以下位置的每個文件/子文件夾都有效:?/the/real/location/wp-content/uploads/

回答

1

我這裏檢查了Apache的手冊,

http://httpd.apache.org/docs/2.4/mod/mod_alias.html#alias

所以說,Alias指令只能在服務器配置或虛擬主機中使用,並在.htaccess文件不允許的。

請始終嘗試查看手冊中任何指令說明的第三行,該行以「Context:...」開頭。因爲它告訴你可以在哪裏使用(以及在不能使用的地方省略)所描述的項目。