Multi-Domain routing
To do this, copy index.php and .htaccess from a.com’s webroot into b.com’s, and make sure the $craftPath variable is correct.

Then, around where $craftPath is getting defined, override $_GET['p'] to make Craft think that the URI actually started with subpath:

$craftPath = '../craft';

$_GET['p'] = 'subpath/' . (isset($_GET['p']) ? $_GET['p'] : '');

// ...


Now when you go to b.com/*, it will be the same as going to a.com/subpath/*.

If you want traffic going to b.com to stay on b.com, you will also need to make sure a.com/subpath is replaced with b.com in any Craft-generated URLs:



{{ url('foo')|replace('a.com/subpath', 'b.com') }}


That will also affect links on a.com, though. If you still want traffic on a.com/subpath to remain on a.com, then it’s slightly more complicated. In your craft/config/general.php file, add a custom domain config setting that varies depending on the requested domain:

return array(
    '*' =&gt; array(
        // ...
    ),
    'a.com' =&gt; array(
        // ...
        'domain' =&gt; 'a',
    ),
    'b.com' =&gt; array(
        // ...
        'domain' =&gt; 'b',
    ),
);


Then in your templates, only run that str_replace filter when the domain is b:



{% set url = url('foo') %}
{{ craft.config.domain == 'b' ? url|replace('a.com/subpath', 'b.com') : url }}