Вопрос

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.

Это было полезно?

Решение

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.

Другие советы

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!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top