Development

HowtoChooseApplicationAndEnvironmentBasedOnDomain (diff)

You must first sign up to be able to contribute.

Changes between Version 2 and Version 3 of HowtoChooseApplicationAndEnvironmentBasedOnDomain

Show
Ignore:
Author:
Lloyd.Leung (IP: 99.247.151.12)
Timestamp:
06/13/07 03:14:39 (10 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowtoChooseApplicationAndEnvironmentBasedOnDomain

    v2 v3  
    1111#!php 
    1212<?php 
    13 define('SF_ROOT_DIR',    realpath(dirname(__FILE__).'/..')); 
     13define('SF_ROOT_DIR', realpath(dirname(__FILE__).'/..')); 
     14 
    1415 
    1516/** 
    1617  * Check for the subdomain admin and make the application admin 
    1718  */ 
    18 if (isset($_SERVER) && is_array($_SERVER) && isset($_SERVER['HTTP_HOST']) && preg_match('/admin\./', $_SERVER['HTTP_HOST'])) 
     19if ( isset($_SERVER) && 
     20     is_array($_SERVER) && 
     21     isset($_SERVER['HTTP_HOST']) && 
     22     preg_match('/admin\./', $_SERVER['HTTP_HOST']) 
     23   ) 
     24
    1925  define('SF_APP', 'backend'); 
    20 elseif (isset($_SERVER) && is_array($_SERVER) && isset($_SERVER['HTTP_HOST']) && preg_match('/telemarket\./', $_SERVER['HTTP_HOST'])) 
     26
     27elseif ( 
     28         isset($_SERVER) && 
     29         is_array($_SERVER) && 
     30         isset($_SERVER['HTTP_HOST']) && 
     31         preg_match('/telemarket\./', $_SERVER['HTTP_HOST']) 
     32       ) 
     33
    2134  define('SF_APP', 'telemarketer'); 
     35} 
    2236else 
     37{ 
    2338  define('SF_APP', 'public'); 
     39} 
     40 
    2441 
    2542/** 
    2643  * Check for the subdomain dev and make the enviorment dev 
    2744  */ 
    28 if (isset($_SERVER) && is_array($_SERVER) && isset($_SERVER['HTTP_HOST']) && preg_match('/dev\./', $_SERVER['HTTP_HOST'])) 
     45if ( isset($_SERVER) && 
     46     is_array($_SERVER) && 
     47     isset($_SERVER['HTTP_HOST']) && 
     48     preg_match('/dev\./', $_SERVER['HTTP_HOST']) 
     49   ) 
    2950{ 
    3051  define('SF_ENVIRONMENT', 'dev'); 
    4263 
    4364sfContext::getInstance()->getController()->dispatch(); 
     65 
    4466}}} 
    4567