3

My question is basically a reflection of the question found here (which unfortunately does not have a clear answer): http://groups.drupal.org/node/20604

Please note that this is not a question about multi-site setup, but it is rather a question about a complicated edge-case; please read through before jumping to suggestions. Also, take a look at the link above if you need more info.

Note also multi-site works generally fine, just not this case.

Some truths:

  • I am using symbolic links (on RHEL5 to be exact)
  • I am using Drupal 6.20
  • I am using Apache
  • I am using subdirectories (NOT subdomains, switching to subdomains is not an acceptable answer)
  • My Drupal site directories are nested two levels deep (e.g. /campus/bus, /campus/news)
  • The Drupal sites all use the same code base in the /campus directory
  • The Drupal sites all use different (their own) databases

In my case, there are dozens of sites, but the first conflict I noticed was as follows. There are two sites at urls such as the below structure:

drupal.drupalsite.com/campus/bus

drupal.drupalsite.com/campus/news

In the sites/[foldername] the respective folders are:

drupal.drupalsite.com.campus.bus

drupal.drupalsite.com.campus.news

The campus folder in the web root contains the Drupal install, and also the symbolic links, so in /var/www/campus there are e.g., news -> ./, bus -> ./.

On the 'bus' subsite, attempting to go to https://drupalsite.com/campus/bus/news makes Drupal confused. It seems to drop everything in the request after the last directory. e.g., drupalsite.com/campus/bus/news will instead resolve to drupalsite.com/campus/bus and drupalsite.com/campus/bus/news/headlines will return a 404 not found.

For another data point, I put a var_dump on $dir in the conf_path() function to see how many directories were being looked at for each request. For a non-conflicting URL, such as bus/undergraduate-programs I got the following:

drupal.drupalsite.com.campus.bus

However for a conflicting URL such as bus/news/headlines I get

drupal.drupalsite.com.campus.bus.news
drupalsite.com.campus.bus.news
com.campus.bus.news
drupal.drupalsite.com.campus.bus

There is a patch which could allow the multi-site setup to be done via sites.php instead of via the method of using symbolic links, however it would involve hacking core, and thus I am not willing to entertain it, though for reference it is here: http://drupal.org/node/231298#comment-3769752

To note, I also tried most of the suggestions in the original groups.drupal.org. thread as well as numerous hacks in .htaccess and my httpd.conf file, all to no avail. Please comment if you need further information to answer the question.

2 Answers 2

2

Are you using just one rewrite? I have this exact setup, and I take care of it with a separate rewrite for each sub-directory. If you just use the default index.php rewrite, the path gets rewritten back to the default, like drupal.drupalsite.com/index.php?q=/campus/news which is where the 404 comes from. I also use aliases in the server level config instead of symbolic links. It makes things cleaner. (Alias /campus/bus /var/www/html/whatever)

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /campus/bus/
RewriteRule ^(.)$ /campus/bus/?q=$1  [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /campus/news/
RewriteRule ^(.)$ /campus/news/?q=$1  [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /
RewriteRule ^(.*)$ ?q=$1  [L,QSA]
5
  • This looks promising. Just to be clear are you doing the RewriteCond in the .htaccess and then your server aliases in your httpd.conf (or whichever Apache conf file) ? Mar 24, 2011 at 22:30
  • 1
    I add both the aliases and the rewrites in custom .conf files in /etc/httpd/conf.d. If you have control over the server there is no reason to use .htaccess files. I have the aliases in my VirtualHost directive and the rewrites in a Directory directive. (the relevant /var/www/html/whatever) Mar 25, 2011 at 0:29
  • Great, ok, I'll give this a shot tomorrow night and then report back if this works as the correct answer. Mar 25, 2011 at 6:40
  • Well, thanks, but no dice. Perhaps with some more info on how you setup your apache conf files I could get this to work, but currently when trying this, the site root still resolves correctly but anything past that ends up at something like /campus/bus/campus/campus/campus/campus/campus... Mar 27, 2011 at 23:55
  • 1
    Did you remove the symbolic links? If you didn't you'll probably end up in loops. If it is a rewrite loop, you can turn on the rewrite log to see what it is doing. Mar 28, 2011 at 2:29
0

I think the setup you have at the moment in sub directories, is a little non standard, and may not be widely supported.

Given that you are already of piste, a small patch to core may be worth trying. Especially as the patch is in D7.

Or you could just switch to D7. No core hackery needed.

1
  • Well, I appreciate the answer, however as stated, switching to D7 and hacking core are both not answers. We have a roadmap to switch to D7 once 90% of the modules we use have stable D7 releases, and then I will personally port the last 10%. With over 20 sites in production, 60 sites in dev, and approximately 3-5 new sites added each week now, all using a set of about 45 modules, we will not be updating right away. Hacking core is a last resort, but unfortunately is not so much an answer as it is a workaround (and one we will have to change a bunch of scripts to support). Mar 21, 2011 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.