Dhi*_*pta 7 log-files apache-2.2
我有一个带有 *.example.com 的 Apache 2.2 VirtualHost ServerName
。这是我的场景所必需的,所有子域都使用同一个站点处理。
现在,在访问日志中,我试图找出一个LogFormat
变量(或方式),让我记录请求的域名。如果我使用的vhost_combined
格式,所有我在访问日志中得到的是* .example.com的条目,而不是在实际的虚拟主机要求。
有人知道怎么做吗?
Ale*_*vic 16
您可以使用%{headername}i
将任何标头的内容放入 LogFormat 指令中,因此%{Host}i
将提供客户端放入 Host: 请求标头中的内容,从而准确地提供您想要的内容。
请参阅http://httpd.apache.org/docs/2.2/mod/mod_log_config.html 上的文档
当您使用例如vhost_combined
Logformat 时:
CustomLog ${APACHE_LOG_DIR}/access.log vhost_combined
Run Code Online (Sandbox Code Playgroud)
您可以vhost_combined
通过添加进行调整%{Host}i
,例如
LogFormat "%v:%p %h %l %u %t %{Host}i \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
Run Code Online (Sandbox Code Playgroud)