Multi-domain routing not working I've followed this answer for running a Craft install based on two domain names. I thought it was working but either I was wrong, or something's changed, because it's not now.

I have a.com (where the Craft install is) and b.com. In b.com's index.php I have this:

$craftPath = '../craft';

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


So that if I go to b.com/directory it loads a page as if it was a.com/subpath/directory.

Except it's not - it's as if it's trying to load a.com/directory.

If I put this in b.com's index.php (after the above):

var_dump($_GET['p']);
exit();


Then I see "subpath/directory", as expected. But if in my base layout template I put this:

{{ craft.request.getQueryString() }}


Then it shows "p=directory". So it seems like "subpath/" is going missing somewhere? I'm stumped.

UPDATE:

If I request b.com/index.php?p=directory then I get the page I expect (ie, /subpath/directory).
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'] : '');