I've run into this error as well and it's doing my head in.
When trying to view pages in the CMS I get the following error in silverstripe.log:
[02-Jul-2015 04:48:35] Warning at framework/control/Director.php line 473: Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set.
So I had a look at the code in question:
if(isset($_SERVER['HTTP_HOST'])) {
return Director::protocol() . $_SERVER['HTTP_HOST'];
} else {
global $_FILE_TO_URL_MAPPING;
if(Director::is_cli() && isset($_FILE_TO_URL_MAPPING)) $errorSuggestion = ' You probably want to define '.
'an entry in $_FILE_TO_URL_MAPPING that covers "' . Director::baseFolder() . '"';
else if(Director::is_cli()) $errorSuggestion = ' You probably want to define $_FILE_TO_URL_MAPPING in '.
'your _ss_environment.php as instructed on the "sake" page of the doc.silverstripe.com wiki';
else $errorSuggestion = "";
user_error("Director::protocolAndHost() lacks sufficient information - HTTP_HOST not set."
. $errorSuggestion, E_USER_WARNING);
return false;
}
The issue seems to be that the code can't read HTTP_HOST. However if I setup a simple flat PHP file like this:
<?php
echo $_SERVER['HTTP_HOST']."<hr/>";
if(isset($_SERVER['HTTP_HOST'])) {
echo "true";
} else {
echo "false";
}
It returns:
www.mysite.com
----------------------------------------------------------------------------------------
true
Which seems to mean that HTTP_HOST is available outside of Silverstripe, but not inside.
Any ideas what's going on?