在apache上限制某些資料不記錄

Apache上,任何連線紀錄都會存在httpd-access.log檔
(依照http.conf設定而有不同)

如果對於特定連線不想在Apache Server留下紀錄
可以用 SetEnvIf 這個參數

需修改http.conf

#不紀錄來自127.0.0.1的連線
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
CustomLog logs/access_log common env=!dontlog



#不紀錄存取robot.txt的連線
SetEnvIf Request_URI "^/robots\.txt$" dontlog
CustomLog logs/access_log common env=!dontlog



SetEnvIf後面可接的參數如下:

Host
User-Agent
Referer
Accept-Language
Remote_Host:
the hostname (if available) of the client making the request.
Remote_Addr:
the IP address of the client making the request.
Server_Addr:
the IP address of the server on which the request was received (only with versions later than 2.0.43).
Request_Method:
the name of the method being used (GET, POST, etc.).
Request_Protocol:
the name and version of the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.).
Request_URI:
the resource requested on the HTTP request line - generally the portion of the URL following the scheme and host portion without the query string.

技術參考
日誌文件 apache

留言

這個網誌中的熱門文章

c語言-關於#define用法

CMD常用網管指令

PHP 與 JavaScript 之間傳值利用 json