Hi all,

I originally posted this under a different Subject which is probably why I didn't get any replies. If anyone is able to help I would really appreciate it.

I've seen numerous posts about how to get multi-site Drupal working with subdirectories but no response that appears to work. So apologies to those of you that are sick of looking at questions like this because I know I am!

Right, I'm running Drupal 4.7, Apache 1.3.33, PHP 4.3.11, and MySQL 4.0.25. If you need other specs shout.

I would like to setup a single Drupal installation at www.example.com and then have several other subsites accessed by going to www.example.com/subsite1 , www.example.com/subsite2 , etc.

The INSTALL.TXT states:
Sites do not each have to have a different domain. You can use subdomains and subdirectories for Drupal sites also. For example, example.com, sub.example.com, and sub.example.com/site3 can all be defined as independent Drupal sites.

It goes on to say:
When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds:

sites/www.sub.example.com.site3/settings.php
etc...

From what the INSTALL.TXT says it appears that I should be able to do exactly what I want but I'm finding it difficult to implement.

I've setup:
sites/default/settings.php
sites/www.example.com.subsite1/settings.php

And configured www.example.com.subsite1/settings.php to use the same database and different tables with table prefixes which I've loaded. To prove categorically that I am indeed using www.example.com.subsite1/settings.php I have put in the an invalid user name for authentication to the database so I should get an error when it finally uses that settings.php config.

When I browse to www.example.com/subsite1 I get page not found. Fair enough, there's nothing telling the webserver that this is a valid URI. So, I put an entry into my .htaccess file as per another posts suggestion that looks like:

RewriteRule ^subsite1/(.*)$ subsite1/index.php?q=$1 [L,QSA]

With that in place now when I browse to www.example.com/subsite1 I see the content of the main site, so I know it's not loading the www.example.com.subsite1/settings.php config.

I've seen other posts about needing to use symlinks but I thought I should be able to do that sort of redirection / rewriting with .htacess but perhaps not in a way that Drupal likes.

If anyone has got this sort of setup I would appreciate some help, or if you know of a post that explains exactly how to get this working.

Thanks in advance,
Miles

Comments

Heine’s picture

I've seen other posts about needing to use symlinks but I thought I should be able to do that sort of redirection / rewriting with .htacess but perhaps not in a way that Drupal likes.

Please try it with symlinks.
--
When your problem is solved, please post a follow-up to the thread you started.

sillygwailo’s picture

I've done this a couple of times, so here are some notes.

  • summarizing the above, the instructions in INSTALL.txt correctly say to create settings.php files in sites/example.com.subsite if the URL is http://example.com/subsite
  • create a symbolic link inside your Drupal directory to the Drupal directory. This sounds a little paradoxical (and it could lead to a situation where you end up changing the directory into the directory you are currently in), but the command line for this I used was the following, while inside the Drupal installation directory, i.e. where index.php lives:
    ln -s . subsite
  • repeat the above two items for each subsite. So
    ln -s . subsite2
    for example.com/subsite2
    after creating the sites/example.com.subsite2 directory and adding settings.php, modules, and themes, etc.

The above might defy easier-to-understand explanation, but if anybody can re-word this better I'd love to put this info as a book page for the multi-site section of the handbook.

(Username formerly my full name, Richard Eriksson.)

drugo303’s picture

I've looked at the function conf_path() (drupal 4.7.2) that search the correct directory splitting the url, but when you have:
sub.example.com/site3 drupal always found sub.example.com for first and the return it.
So the function never tries sub.example.com.site3/setting.php.
I've also tried to hardcode the correct directory but when it checks file_exists() with $conf_dir/sub.example.com.site3/setting.php it always return false.
I don't know what to do beacuse changing conf_path() can compromise the correct display of themes, for example when your url is like:
example.com/taxonomy/term/1.