Changeset 2177

Show
Ignore:
Timestamp:
02/27/2008 12:47:04 PM (11 months ago)
Author:
gregmac
Message:

Add support for blank site_protocol (if not explicity passed to base, tries to auto-detect http or https); Add support for auto-detecting domain part of site_domain from HTTP_HOST; Add fallback support for blank site_domain (makes a best effort)

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/config/config.php

    r2003 r2177  
    22/** 
    33 * Domain name, with the installation directory. Default: localhost/kohana/ 
     4 * If this starts with a /, Kohana will try to get the domain from HTTP_HOST 
     5 * from  the web server. 
    46 */ 
    57$config['site_domain'] = 'localhost/kohana/'; 
  • trunk/system/helpers/url.php

    r2017 r2177  
    2222        { 
    2323                $protocol = ($protocol == FALSE) ? Config::item('core.site_protocol') : strtolower($protocol); 
     24                // try to auto-detect protocol 
     25                empty($protocol) AND $protocol = (isset($_SERVER['HTTPS']) AND ($_SERVER['HTTPS'] != '')) ? 'https' : 'http'; 
    2426 
    25                 $base_url = $protocol.'://'.Config::item('core.site_domain', TRUE); 
    26  
     27                $site_domain = Config::item('core.site_domain', TRUE); 
     28                // Add current servername if site_domain starts with a / 
     29                (strlen($site_domain) > 0 AND $site_domain[0] == '/') AND $site_domain = $_SERVER['HTTP_HOST'].$site_domain; 
     30                 
     31                // if site_domain is empty, no base url. This results in  
     32                // a relative path (eg, "index.php/") being returned 
     33                $base_url = (!empty($site_domain)) ? $protocol.'://'.$site_domain : ''; 
     34                 
    2735                if ($index == TRUE AND $index = Config::item('core.index_page')) 
    2836                {