From 4c2406db29af7a904b8196ffc5c662be39ec1a47 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 2 Apr 2012 20:45:20 -0500 Subject: [PATCH] fixing base url generation. --- laravel/url.php | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/laravel/url.php b/laravel/url.php index 9268a0d5..c622e3bf 100644 --- a/laravel/url.php +++ b/laravel/url.php @@ -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. *