0620~0623 apache日志切割 不记录 静态缓存 防盗链0620 日志切割日志配置:httpd-vhosts.conf虚拟主机配置里CustomLogCustomLog "|/usr/local/apache2/bin/rotatelogs -l /tmp/access-%Y%m%d.log 86400" combineddate -s "2015-01-14 01:01:01" 修改时间和日期日志格式:httpd.conf 第205行 LogFormatLogFormat %h 访问IP %u 验证用户 %t 时间 %r 动作 %>s 状态码 0621 不记录指定文件类型URI 网址结尾/后面的字符在虚拟主机配置里面给不记录的URI设定一个标记 SetEnvIf Request_URI ".*\.gif$" image-request SetEnvIf Request_URI ".*\.png$" image-request SetEnvIf Request_URI ".*\.jpg$" image-request SetEnvIf Request_URI ".*\.ico$" image-request SetEnvIf Request_URI ".*\.js$" image-request SetEnvIf Request_URI ".*\.css$" image-request然后在CustomLog 最后加上 env=!image-request0622 配置静态缓存 <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/gif "access plus 2 hours" ExpiresByType image/png "access plus 2 hours" ExpiresByType image/jpg "access plus 2 hours" ExpiresByType text/css "now plus 2 hours" ExpiresByType application/x-javascript "now plus 1 hours" ExpiresBytype application/x-shockwave-flash "now plus 1 hours" ExpiresDefault "now plus 0 min" </IfModule>0623 防盗链 SetEnvIfNoCase Referer "http://www\.f\.com" loc_ref <filesmatch ".*\.(gif|jpg|swf|rar|zip|gz|bz2|7z|png)"> Order Allow,Deny Allow from env=loc_ref </filesmatch>
编辑回复