Commit 4c2406db authored by Taylor Otwell's avatar Taylor Otwell

fixing base url generation.

parent 2276c670
...@@ -68,38 +68,16 @@ class URL { ...@@ -68,38 +68,16 @@ class URL {
{ {
$base = $url; $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; 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. * Generate an application URL.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment