Eventually i would like to create automatic "website" using the multi-site feature, but am having trouble figuring out which config to use in .htaccess. I currently use httpd.conf but need a more automatic way of doing this, rather than restarting the webserver for every new site.

So i tried the following lines in .htaccess...

Alias /drupal/site1 "C:/Program Files/Apache Group/Apache/htdocs/drupal"

but to no avail. What am i doing wrong? Those line works in httpd.conf

Also, in order to have automatic website, I intend to create a module, (i have to anyway), that will find out if there is a registration in process and then automatically create a website for them such that their url will be www.examdple.com/(member name).

Once i find out the correct codes to use in .htaccess, I plan on appending the correct codes to the .htaccess every time a new member register. But I have a feeling that this may not be the most efficent way to do.

Is there a better way to do this, perhap have only a few line of codes in .htaccess that works for all sites using the multi-site feature?

Please keep in mind, this is only for .htaccess file (not httpd.conf file).



bluedrupal’s picture

I also searched all over drupal site and the web for a module that could do this. I even also spend 2 days straight reading the handbook available here at Drupal.org (am a college student and have a summer break whoohoo) I even went to Apache site and read up on htaccess file, but it does not provide much help or if it did, i didnt understand it.

If you know of a site that can provide me some direction, please post it, it will be greatly appreciated.



media girl’s picture

What about php.ini settings?

If I understand you, you're trying to automate adding another site to a multi-site installation, which means changing/adding "settings" directories at the very least. Are the added sites going to have their own database tables? It sounds like you'd need some unix scripting to do a bit of this. Sorry I don't have any specific advice, but my hunch is that a php module could not do everything you need, though I could be wrong. I often am. ;)


bluedrupal’s picture

Yes, that is what i would like to do.

Basically the "automation" module will create a directory and add setting.php with its own configuration for each member, with one database for all members, with possibility of having a database for each member (creating tables with prefixes like (username)_access and so forth).

I will not have access to httpd.conf or php.ini, it will be on remote server so my option is limited, which is why I asks about htaccess file. I saw that file as an opportunity to do automated website for each member.

Am I looking in the wrong place? Are there other way of doing this without relying on httpd.conf or php.ini because i do not have access to those.

Do you know of a better way of doing this with the restriction of not having access to httpd.conf or php.ini. Basically doing this with your typical remote hosting space.


media girl’s picture

Using php.ini is possible on the hosting plans I have. The file must reside in the subdirectory where the code that's to be affected resides ... but I'm not sure how php.ini, which afaik is a way merely to override default php settings, would do what you need. (I used it to extend php timeout settings.)

With each installation, afaik, you need an .htaccess file in each installation's base subdirectory, with the base url path designated in the file. The rest is pretty much boilerplate.

Anyway, this area is not exactly my specialty so I defer to wiser souls here.


bluedrupal’s picture

If i were to use php.ini, exactly what commands would I put in there to allow multi-site and where do i place this file? Does it allow aliases?

As for .htaccess, would u know what command should be in the file to allow aliases?



bluedrupal’s picture

Bumping this in hope to get reply and/or help from the Drupal experts.

Someone has got to know how to do this!


bluedrupal’s picture

Bumping this once more in hope of getting help on this.

jeff h’s picture

I can't find anywhere on drupal.org clear instructions for what must be done to achieve clean URLs with multisites.

I discovered a thread at http://drupal.org/node/37177#comment-68606 which describes four extra lines to add into the drupal install directory's .htaccess file.

Is this the only way? Do I have to add these four lines to this .htaccess every time I add a new "sub" site? I plan on setting up about 200 subsites!


deprecated’s picture

I'm not a programmer, and I've never written a Drupal module, but maybe you could now use WorkFlow to call a php file with the commands you need run on you server using the exec() command. This would happen after succesful registration. Or with 4.6 you could add a link somewhere My Account somehow, or a special block. You could probably copy from a master settings.php file and then change stuff in it with PHP.

I host on Godaddy. I got multisite to work by calling a custom php file in the root directory that contained only this:

  exec ('ln -s . subdirectory');

Then you can reach the site with www.sitename.com/subdirectory. (after adding sites/sitename.com.subdirectory/settings.php, of course)

Hope this helps.

farooqsadiq’s picture

My solution to getting Clean URL working with my multisite setup drupal 4.7

I added Alias to my httpd.conf apache file

<VirtualHost *:80>
    # Alias for all php drupal sites
    Alias /abc /var/www/html/drupal
    Alias /def /var/www/html/drupal
    Alias /xyz /var/www/html/drupal

My setup has 4 sites /drupal, /abc, /def, /xyz all files are in the /drupal directory

  • url=/drupal (sites/default/)
  • url=/abc (sites/localhost.abc/)
  • url=/def (sites/localhost.def/)
  • url=/xyz (sites/localhost.xyz/)

In the /drupal/.htacess file. I added a RewriteCond %{REQUEST_URI} condition for
each site, and so have separate RewriteRule for each site.
No need for the RewriteBase directive, leave it commented out

  #RewriteBase /drupal  DO NOT NEED THIS, COMMENT OUT

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

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/abc/(.*)$
  RewriteRule ^(.*)$ /abc/index.php?q=$1 [L,QSA]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/def/(.*)$
  RewriteRule ^(.*)$ /def/index.php?q=$1 [L,QSA]

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

Note: each site has its own database aswell as files, modules and themes directories in the corresponding sites/localhost.site/ directory.

cogdog’s picture

Thanks for these steps which got me past the setup bumps in multi-sites. Mine will too be directory based from a main URL, and also have to co-exist with the legacy old static HTML content which the new site will replace only some of the content. I was able to set up the /drupal directory parallel to my web content/htdocs directory.

My strategy is to develop the new site at a temp directory http://www.mysite.org/beta with other sites http://www.mysite.org/project1 and http://www.mysite.org/project2

and I can later change the drupal configs so the primary site eventually serves from http://www.mysite.org/

/* ********************************************
Alan Levine: A Cog, a Dog, A Blog
Go Dog Go! http://cogdogblog.com
******************************************** */

apeman’s picture


Thanks for that great solution, it works for me on my localhost machine (MAC OS X with PHP 4 and Apache 2), but it doesn´t work on my online server (WinXP with PHP4 and Apache 2).

It always adds /php/ to a link :-( Maybe it´s because PHP is not running as a Apache Module?

I give in the domain www.test.com/en
and all links on the site are changed into

What´s the htaccess command to delete that /php/ attachment?



jsloan’s picture

Some of the discussion here may help: http://drupal.org/node/69199#comment-129840

apeman’s picture

Thanks, I have the solution, I forgot to set a basedirectory in settings.php, now it works!

rorysolomon’s picture


Thanks so much! that is a great idea. I was totally stumped just now on how to do this and you saved me. (I'm just using symlinks under my webroot and so I don't need the virtual host aliases, but otherwise the same.)


SocialNicheGuru’s picture


Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.

pan69’s picture

It seems to work for me in that it doesn't throw any error. Actually, on my localhost box it runs perfectly my on the live server I see the URL change but it always seems to load the home page of my site.

Any ideas?


Wolfflow’s picture

Hi All, I have a Multisite installation on Localhost on my Test Lan.

What I need to know is if the code (.htaccess) example on http://drupal.org/node/25011#comment-136227 here
is being applyed by Drupal 5.x and Drupal 6.x multisite installations. Your feedback here might help others reading this.


Share your experience with the Open Source Community it's not only a choice but a Life Philosophy !!!
Some interesting A New Tutorial Site

Contact me for drupal projects in English, German, Italian, Drupal Hosting Support.

ibragim’s picture

Steel present solution without editing apache *.conf file?

dorian_’s picture

Hi there,

I figured out a solution for multisite(s) in subdirectories using a symlink.

here's a snippet of my .htaccess-File (modified Drupal standard-.htaccess):

...here we go...

# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
RewriteBase /

# 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]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /YOUR_SUBDIRECTORY/index.php?q=$1 [L,QSA]

It took me 1 day to figure it out!

I hope it helps someone...

ronsnow’s picture

This is most frustrating, probably part due to server variance (anhosting.com servers) and lack of a smooth multisite config for drupal.
I have the following sites that I need supported in a multisite installation of drupal 6.16 installation in a production subdirectory ('prod'):

So I have all seemingly correct, I have the following:

(The last four have 'settings.php' and all has all the /modules and /themes)

I have the default site working. BUT when I got to example.com/subdir1 or any of them, I just get the default site error page with a 'Not Found' error along with the normal page layout.

I put in symlinks in: public_html/prod/subdir1 to point to 'prod' directory and that works, at least in the file manager interface I can open the 'public_html/prod/subdir1' symlink and I get the same 'prod' directory. However, when I try to go to www.example.com/subdir1 I get a security error - denied access message because I don't have permissions to access 'prod/subdir1'. You can't change permissions on symlinks --- my control panel interface shows them as '0000' security instead of '0655', yet the shell access shows them as '777'.

I have tried all the fixes to .htaccess in this and related article but can not get my multisite config to work. I just get stuck on the default - that is the only one working. The other sites directory entries for the sub-directories never are accessed by drupal.

Any body have some ideas that might work in a drupal 6.16 environment or any workarounds???

Any one have some good ideas on this?

Wolfflow’s picture

There are many way and structure to implement a Drupal Multisite Install, take a look here: Advanced and multisite installation

Contact me for drupal projects in English, German, Italian, Drupal Hosting Support.

lpalgarvio’s picture

here's some .htaccess code

redirect domain.tld to www.domain.tld, but not other subdomains (like site2.domain.tld):

  # Redirect all users to access the site WITH the 'www.' prefix
  RewriteCond %{HTTP_HOST} !^www\. [NC]
  RewriteCond %{HTTP_HOST} !\.([a-z-]+\.[a-z]{2,6})$ [NC]
  RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

redirect www.domain.tld to domain.tld, but not other subdomains (like site2.domain.tld):

  # Redirect all users to access the site WITHOUT the 'www.' prefix
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteCond %{HTTP_HOST} !\.([a-z-]+\.[a-z]{2,6})$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]

based on D7 .htaccess with inclusion of no other subdomains condition

Luís Pedro Algarvio
Drupal Linux DevOps