Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable apending of "referer" to error_log in PHP?

PHP error logs typically look something like this:

[Tue Sep 02 15:46:13 2014] [error] [client 192.168.0.105] blah, blah, ... , referer: https://192.168.0.21/blah/blah
[Tue Sep 02 15:46:13 2014] [error] [client 192.168.0.105] blah, blee, ... , referer: https://192.168.0.21/blah/blee

How can I get them to look like this?

[Tue Sep 02 15:46:13 2014] [error] [client 192.168.0.105] blah, blah, ... 
[Tue Sep 02 15:46:13 2014] [error] [client 192.168.0.105] blah, blee, ... 

I tried $_SERVER['HTTP_REFERER']=''; but it (not surprisingly) didn't help.

like image 633
Dwayne Towell Avatar asked Sep 02 '14 20:09

Dwayne Towell


1 Answers

(replying to an old question, I know, but I had to figure this out on my own recently, so maybe this will help somebody else...)

This can be done by setting the 'ErrorLogFormat' directive, either in your server config or virtualhost .conf file. Like this:

ErrorLogFormat "[%t] [%l] [pid %P] %F: %E: [client %a] %M"

Or maybe look up the default in your server config and modify that - you just need to get rid of %{Referer}i, which is what adds the referer url.

like image 182
corvidism Avatar answered Nov 02 '22 11:11

corvidism