fixing base url generation.
This commit is contained in:
parent
2276c6705c
commit
4c2406db29
|
@ -68,38 +68,16 @@ public static function base()
|
|||
{
|
||||
$base = $url;
|
||||
}
|
||||
elseif (isset($_SERVER['HTTP_HOST']))
|
||||
else
|
||||
{
|
||||
$base = static::guess();
|
||||
$f = Request::foundation();
|
||||
|
||||
$base = $f->getScheme().'://'.$f->getHttpHost().$f->getBaseUrl();
|
||||
}
|
||||
|
||||
return static::$base = $base;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the application URL based on the $_SERVER variables.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function guess()
|
||||
{
|
||||
$protocol = (Request::secure()) ? 'https://' : 'http://';
|
||||
|
||||
// Basically, by removing the basename, we are removing everything after
|
||||
// the and including the front controller from the URI. Leaving us with
|
||||
// the installation path for the application.
|
||||
$script = $_SERVER['SCRIPT_NAME'];
|
||||
|
||||
$path = str_replace(basename($script), '', $script);
|
||||
|
||||
// Now that we have the URL, all we need to do is attach the protocol
|
||||
// protocol and HTTP_HOST to build the URL for the application, and
|
||||
// we also trim off trailing slashes for cleanliness.
|
||||
$uri = $protocol.$_SERVER['HTTP_HOST'].$path;
|
||||
|
||||
return rtrim($uri, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an application URL.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue