配置Apache静态缓存及防盗链需要在虚拟主机文件下面添加一下参数
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
ExpiresActive on
ExpiresByType image/gif "access plus 1 days" #gif图片缓存1天
ExpiresByType images/jpeg "access plus 24 hours" #jpeg图片缓存24小时
ExpiresByType image/png "access plus 24 hours" #png图片缓存24小时
ExpiresByType test/css "now plus 2 hours" #css温家岸缓存2天
ExpiresByType application/x-javascript "now plus 2 hours" #javascript文件缓存2小时
ExpiresByType application/x-shockwave-flash "now plus 2 hours" #flash文件缓存2小时
ExpiresDefault "now plus 0 min" 默认缓存分钟
SetEnvIfNoCase Referer "^http://.*\.youdomain\.com" local_ref 白名单
SetEnvIfNoCase Referer ".*\.youdomain\.net" local_ref 白名单
防盗链的文件类型
Order Allow,Deny
Allow from env=local_ref
Deny from all
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
ExpiresActive on
ExpiresByType image/gif "access plus 1 days" #gif图片缓存1天
ExpiresByType images/jpeg "access plus 24 hours" #jpeg图片缓存24小时
ExpiresByType image/png "access plus 24 hours" #png图片缓存24小时
ExpiresByType test/css "now plus 2 hours" #css温家岸缓存2天
ExpiresByType application/x-javascript "now plus 2 hours" #javascript文件缓存2小时
ExpiresByType application/x-shockwave-flash "now plus 2 hours" #flash文件缓存2小时
ExpiresDefault "now plus 0 min" 默认缓存分钟
SetEnvIfNoCase Referer "^http://.*\.youdomain\.com" local_ref 白名单
SetEnvIfNoCase Referer ".*\.youdomain\.net" local_ref 白名单
防盗链的文件类型
Order Allow,Deny
Allow from env=local_ref
Deny from all
编辑回复