Multi-domain routing not working
I've found an answer, but I don't know if it's going to cause me any problems or not. Looking at the debug output in the JS Console I noticed that although
$_GET['p'] was set correctly to subpath/directory,
$_SERVER['REQUEST_URI'] was only set to /directory and
$_SERVER['QUERY_STRING'] was only set to p=directory. Maybe Craft or Yii uses the REQUEST_URI rather than $_GET['p'] at some crucial stage?

So I've replaced the $_GET['p']... line in my b.com/index.php with this:

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


That seems to fix things. Any reason this might be bad and wrong?

UPDATE: Looking back at my code now, it seems that both lines were required, to cover all occasions. So I now have this in b.com/index.php:

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

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