The Request:
I was asked to set up a multisite installation using one Drupal install and one database.
www.example.com/site1
At www.example.com is a static site with an index.htm that needs to be preserved.
My ultimate goal is to have ONE drupal installation in the root, ie: www.example.com
and to move www.example.com/site1 into www.example.com/sites/example.com.site1.
I then want to add a second www.example.com/sites/example.com.site2 and have them all share profiles, users, roles and sessions.
The Solution:
I installed Drupal in the root directory. I added a redirect (through cPanel) so that entering www.example.com points to the index.htm file and not the drupal index.php (until this static site is moved over onto drupal).
I created sites/example.com.site1 and a settings.php file that points to an empty database. I created a symlink that redirects from www.example.com/site1 to www.example.com/index.php. (See:
How to Create Symbolic Links Using PHP).
The rest of the solution is in the .htaccess file. I've pasted the important parts of the file (substitute directory1 and directory2 with your directory names).
# Set the default handler.
DirectoryIndex index.htm
# Drupal Sub-directory sites - need one of these for each sub-directory site.
# Re-direct request for sub-directory root to index.php
# This allows the Default Handler to be something other than index.php for the top-level site,
# but re-writes access to any sub-directory root to the Drupal default: index.php
# This is needed ONLY so long as the DirectoryIndex is not index.php
# (i.e., once the top-level static site is convereted to Drupal, change DirectoryIndex = index.php
# and get rid of these sub-directory re-write rules, leaving only the main rule (for clean-urls)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} =/directory1/
RewriteRule ^(.*)$ index.php?=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} =/directory2/
RewriteRule ^(.*)$ index.php?=$1 [L,QSA]
# Clean URLs: Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]