views:

465

answers:

0

I have been using the below code in my Bootstrap.php file in CakePHP to detect subdomains, which appears to work really well.

preg_match('/^(?:www\.)?(?:(.+)\.)?(.+\..+)$/i', env('HTTP_HOST'), $matches); 
define('SUBDOMAIN', empty($matches[1]) ? false : $matches[1]); 
define('HOST', $matches[2]); 
define('BASE_URL', 'http://' . HOST); 
if(SUBDOMAIN) {
    debug (BASE_URL);
    debug (HOST);
    debug (SUBDOMAIN);
    exit;
}

All good. Now, what I want to do is enable these subdomains to be mirrored using DNS CNAMES in the same way that you can with cname.createsend.com (Campaign Monitor). Thanks in advance.