Lighttpd mod_accesslog 无法显示带有自定义错误页面的 Request_URI
我需要一些帮助来自定义 Lighttpd 1.4.28 上的访问日志。到目前为止,我已经能够修改配置以在 strftime(3) 格式。默认日期格式太长。以下是 /etc/lighttpd/lighttpd.conf
中的相关行
accesslog.format = "%s [%{%d%b-%H:%M}t] %h %b %U * %{From}i|%{Via}i|%{Referer}i *
accesslog.filename = "/web/lighttpd_access.log"
这是我的 access.log 条目:
404 [24Aug-16:55] 98.68.178.112 345 /phpMyAdmin/scripts/setup.php * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
自定义日期并不难,但我在尝试同时显示请求 URL 时遇到了问题使用自定义 404 页面。我刚刚添加
server.error-handler-404 = "/error.html"
到 lighttpd.conf
文件中,lighttpd_access.log
现在包含重定向的 /error.html
,而不是完整的 url生成错误的请求。
200 [24Aug-16:06] 98.68.178.112 1 /error.html * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
我还尝试添加 %{Request_URI}i
,但日志条目 -
为空。有人知道在尝试与自定义 404 页面一起显示原始请求 URL 时要使用的正确语法吗?
I need some help to customize my access log on Lighttpd 1.4.28. So far I have been able to modify the configuration to display the date in a strftime(3) format. The default date format is just way too long. Here are the relevant lines from /etc/lighttpd/lighttpd.conf
accesslog.format = "%s [%{%d%b-%H:%M}t] %h %b %U * %{From}i|%{Via}i|%{Referer}i *
accesslog.filename = "/web/lighttpd_access.log"
And here is my access.log entry:
404 [24Aug-16:55] 98.68.178.112 345 /phpMyAdmin/scripts/setup.php * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
Customizing the date was not hard, but I ran into a problem trying to display request URL while simultaneously using custom 404 pages. I just added
server.error-handler-404 = "/error.html"
to the lighttpd.conf
file, and the lighttpd_access.log
now contains redirected /error.html
, instead of the full url of the request that generated the error.
200 [24Aug-16:06] 98.68.178.112 1 /error.html * -|-|- * "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1"
I have also tried adding %{Request_URI}i
, but the log entry was -
blank. Anyone knows the correct syntax to use when trying to display the original request URL in conjunction with custom 404 pages?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这并不是对您的问题的精确解决,但如果您的目标只是找出哪些 URL 被破坏 - 使用 PHP 文件代替您的错误处理程序 - 您仍然可以重定向到 error.html (如果您愿意)
lighttpd .conf:
错误.php:
This isn't an exact fix to your issue but if your goal is just to find out what URLs are broken - use a PHP file instead for your error handler -- you can still redirect to error.html (if you so wish)
lighttpd.conf:
error.php: