S
S
Sergey Yakushev2021-03-10 11:10:25
Apache HTTP Server
Sergey Yakushev, 2021-03-10 11:10:25

Does Apache2 have an analogue of the substing function or another way to log part of the header?

It is necessary to write the first 8 characters of the request header value to the log file.

If the line that records the full name of the UserAgent looks like this:
CustomLog ${APACHE_LOG_DIR}/access.log "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \" %{User-Agent}i\""

what should I do if I'm only interested in the first 8 characters of the user agent?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2021-03-10
@stopa85

First copy those first 8 characters into a separate variable. You can use this new variable like this:
SetEnvIf User-Agent ^(.{0,8}) VarName=$1
%{VarName}e

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question