Setting up drupal multisite on localhost (with Apache Alias)

In this blog post I am going to explain about setting up drupal multisite with Apache Alias and it is a continuation of previous blog post where i explained about using single drupal installation to host more than one site with quiz module branches (quiz 3.x and quiz 4.x) as example.
There we created two sites one for each branches and the sites are accessible from the URL http://quiz3dev and http://quiz4dev
Well that is fine and works out of box. Thanks a ton to drupal. Imagine the case where you want to use the same domain name across the sites and wants to access like
http://mysite.com/site1
http://mysite.com/site2
..
http://mysite.com/siteN
The method described in the previous blog posts uses Apache VirtualHost concepts which requires about 10 lines of entries in Apache configuration file /etc/apache2/sites-enabled/000-default for each site
ServerAdmin drupal@localhost
DocumentRoot "/home/sivaji/Public/d6/"
ServerName quiz3dev
<Directory "/home/sivaji/Public/d6/">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Probably this is not the good, though it helps to achieve the thing we need. Apache alias is an another way to setup drupal multisite with domin name shared across the individual sites.
The procedure to set up is as follow.
1. Creating directory structure similar step 3 in previous blog post

2. Add lines to .htaccess
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/quiz3dev/(.*)$
RewriteRule ^(.*)$ /quiz3dev/index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/quiz4dev/(.*)$
RewriteRule ^(.*)$ /quiz4dev/index.php?q=$1 [L,QSA]
This should go between line # RewriteBase / and # Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
Remember the above lines uses the name that comes after domain name http://localhost/quiz3dev/ and http://localhost/quiz4dev/ you need to replace quiz3dev and quiz4dev to suit your set up.
3. Add alias in Apache configuration file /etc/apache2/sites-enabled/000-default
Alias /quiz4dev "/home/sivaji/Public/d6"
where /home/sivaji/Public/d6 is the path to root of drupal file system.
That's all we are done. Now the URL http://localhost/quiz3dev and http://localhost/quiz4dev will take you to quiz 3.x and quiz4.x site respectively.
- sivaji's blog
- Login to post comments

Comments
this works great on server computer (http://localhost/site1, localhost/site2) ... but if I want to see the site from other computer in lan, it only shows the /default site ... no matter the alias ... (192.168.X.X/site1,192.168.X.X/site2 ==> 192.168.X.X/default )
If you have any suggestion on this what should i do .. please tell me ... thank you ..
Hi there, I dont know if I am writing in a proper board but I have got a problem with activation, link i receive in email is not working... http://www.caucusllc.com/?18aa358d7f273b50fa6156ba07d,
I need
ls sitescommand output from drupal root directory.I guess the current sites folder are like
localhost.site1, localhost.site2, etc.so it works fine for URL http://localhost/site1, http://localhost/site2, etc. To access from URL http://192.168.X.X/site1 you need to create symbolic links like$ ln -s localhost.site2 192.168.X.X.site2
dud ... u rule ! this works .. thank you !
Just Clean URLs don't work but this is not really a problem for devel site ... thank you again ..
actually, it is a problem ..