Site aliases do not work for Drupal sites where the drupal root is not at the document root of the web server.
| Project: | Drush |
| Version: | All-Versions-HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
As I mentioned in #624856: Multisite: How to specify ~/sites/mydomain.com.mysite in the command-line options?, site aliases do not work for sites where the drupal root is in some sub-path rather than directly at the root of the web server. For example, if the drupal site is at http://domain.com/drupal, then the uri is also "domain.com/drupal", but the settings.php file is located in "domain.com.drupal". The site alias code expects that the uri should be located in a folder with the same name as the uri, that is "domain.com.drupal". The fact that the uri is different causes minor problems; however, most things still work.
Similar problems occur if you actually put the 'http://' on the front of the uri in a site alias. This should also be allowed.
I will post a patch to fix this here once I have one ready.

#1
Patch attached. Makes site aliases work correctly with sites where the site directory might contain a port or path component.
Also,
drush sa defaultwill now print out information about the default site -- that is, whichever site is set with -l or --uri. This is useful for setting up site aliases for the first time using --root, --uri and --full. "default" can also be used in other contexts, such as drush sync and drush sql sync.#2
Patch updated.
I realised that "default" should be reserved to mean the default Drush site, so I changed the reserved word to "current" (i.e.
drush sa current) to indicate the current site specified by -l / --uri.#3
+++ includes/sitealias.inc 7 Nov 2009 14:44:37 -0000@@ -263,30 +277,82 @@ function _drush_sitealias_build_record_f
+ //$drupal_root = drush_get_context('DRUSH_DRUPAL_ROOT');
lets omit the commented out code
+++ includes/sitealias.inc 7 Nov 2009 14:44:37 -0000@@ -263,30 +277,82 @@ function _drush_sitealias_build_record_f
+function drush_sitealias_site_dir_from_filename($site_settings_file) {
+ $path = explode('/', $site_settings_file);
+ array_pop($path); // pop off 'settings.php'
+ $site_dir = array_pop($path); // get the directory name that settings.php is in
+
+ return $site_dir;
+}
looks same as dirname($site_settings_file). am i wrong?
#4
1. Whoops. Removed.
2. Almost; it is the same as basename(dirname($site_settings_file)). I changed the implementation to that; the previous implementation was taken from another part of Drush. My favorite kind of code is tested code, but using the platform libraries is even better.
#5
The previous patch accidentally included a modified version of the 'drush' script. Use this patch instead.
#6
committed. thx.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.