Processing of site aliases does not work when the alias contains part of the URI after the HOST_NAME.

For example, if I have a site located at sites/example.com, and I use sites.php to create an alias with

$sites['localhost.example'] = 'example.com';

and browse to http://localhost/example, Drupal will load the site from sites/default instead of following the alias to sites/example.com.

According to the example from line 43 of examples.sites.php, this alias should work.

I am relatively new to Drupal so I may be missing something here, but it seems to me that this problem is not limited to sites.php, but that any site directory that contains the portion of the URI between the HOST_NAME and the SCRIPT_NAME would not work.

In conf_path of bootstrap.inc. It seems that, somehow, $_SERVER['REQUEST_URI'] should be used in generating the $uri array, around line 552.

I quickly changed line 552 to

$uri = explode('/', $_SERVER['REQUEST_URI'].($_SERVER['SCRIPT_NAME'] ? $_SERVER['SCRIPT_NAME'] : $_SERVER['SCRIPT_FILENAME']));

and that solved the sites.php alias problem, but I think this would cause other problems if $_SERVER['SCRIPT_NAME'] was unset.

Comments

gprestwood’s picture

Title: sites.php does not work for aliases aliases like "localhost.example" » sites.php does not work for aliases like "localhost.example"

Version: 7.17 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.