找到: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
再后面加上图片文件的类型
SetEnvIf Request_URI \.gif$ gif-image
SetEnvIf Request_URI \.GIF$ gif-image
SetEnvIf Request_URI \.jpg$ gif-image
SetEnvIf Request_URI \.JPG$ gif-image
SetEnvIf Request_URI \.png$ gif-image
SetEnvIf Request_URI \.js$ gif-image
SetEnvIf Request_URI \.bmp$ gif-image
SetEnvIf Request_URI \.css$ gif-image
SetEnvIf Request_URI \.mid$ gif-image
SetEnvIf Request_URI \.swf$ gif-image
SetEnvIf Request_URI \.mmf$ gif-image
SetEnvIf Request_URI \.wma$ gif-image
SetEnvIf Request_URI \.midi$ gif-image
记日志时
CustomLog /usr/local/apache/logs/access.log combined env=!gif-image
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
再后面加上图片文件的类型
SetEnvIf Request_URI \.gif$ gif-image
SetEnvIf Request_URI \.GIF$ gif-image
SetEnvIf Request_URI \.jpg$ gif-image
SetEnvIf Request_URI \.JPG$ gif-image
SetEnvIf Request_URI \.png$ gif-image
SetEnvIf Request_URI \.js$ gif-image
SetEnvIf Request_URI \.bmp$ gif-image
SetEnvIf Request_URI \.css$ gif-image
SetEnvIf Request_URI \.mid$ gif-image
SetEnvIf Request_URI \.swf$ gif-image
SetEnvIf Request_URI \.mmf$ gif-image
SetEnvIf Request_URI \.wma$ gif-image
SetEnvIf Request_URI \.midi$ gif-image
记日志时
CustomLog /usr/local/apache/logs/access.log combined env=!gif-image
0
另外一种方式:
- <VirtualHost *:80>
- DocumentRoot /data/web/
- ServerName www.test.com
- SetEnvIf Request_URI ".*\.gif$" image-request
- SetEnvIf Request_URI ".*\.jpg$" image-request
- SetEnvIf Request_URI ".*\.png$" image-request
- SetEnvIf Request_URI ".*\.bmp$" image-request
- SetEnvIf Request_URI ".*\.swf$" image-request
- SetEnvIf Request_URI ".*\.js$" image-request
- SetEnvIf Request_URI ".*\.css$" image-request
- CustomLog "/logs/access.log" combined env=!image-request
- </VirtualHost>
编辑回复