Reputation: 643
I am getting the same error in my apache error log as described in this question. The only difference is that I am using $_SERVER as described in the answer.
Line 8 is:
if(strstr($_SERVER['HTTP_HOST'],'127.0.0.1'))
The same error appears for line 59 which has the exact same conditional. It's a conditional to tell the website whether we are in sandboxing or not. As far as I can tell nothing bad is happened except it is clogging up the apache error log.
Does anyone know why this is happening and how to fix it? The PHP version is 5.3.10. The server is running Ubuntu 12.04.
Thank you.
Upvotes: 1
Views: 12217
Reputation: 2355
FWIW, certain crawlers don't send HTTP_HOST
info; Googlebot is one. Be sure to check your access log, entries where a crawler has hit the site will coincide with the timestamp in the error log, for example:
8.8.8.8 - - [28/Nov/2016:15:24:23 +0000] "GET / HTTP/1.0" 200
20463 "-" "Mozilla/5.0 (compatible; Googlebot/2.1;
+http://www.google.com/bot.html)"
The corresponding error log entry:
[Mon Nov 28 15:24:23.579216 2016] [:error] [pid 28226]
[client 8.8.8.8:20463] PHP Notice: Undefined index: HTTP_HOST
in /var/www/public_html/site/script.php on line 5
Thanks Googlebot!
Upvotes: 2
Reputation: 2948
The manual implies this index may not always be set http://php.net/manual/en/reserved.variables.server.php
Contents of the Host: header from the current request, if there is one.
Upvotes: 3