I've asked this before at http://drupal.org/node/25011 but to no avail.

So I'll try to ask this in a different way.

If I want to do automatic multi-site feature without having to manually create folders in the "sites" directory and manually go into httpd.conf file and append it, how would I go about this?

Appending to httpd.conf is not something I can do because I dont have access to it. I've tried to add "Alias" to .htaccess file, but it gave me an error.

I've read on .htaccess file, and about what it can do. From what I understand, .htaccess can do anything httpd.conf can do. It basically just overrides settings. But for some reason, .htaccess will not accept the Alias statement.

Back to my question, how would I proceed? What technology do I need to look at to make this happen? If possible please post hints and code that will point me in the right direction. I've been trying to do this for the past week.

Comments

tag-1’s picture

Not all directives will work in .htaccess files; for example, it makes no sense to allow a ServerName directive to appear in one, since the server is already running and knows its name -- and cannot change it -- by the time a request would cause the .htaccess file to be read. Other directives aren't allowed because they deal with features that are server-wide, or perhaps are too sensitive.

this is from the following page which you should also read: http://apache-server.com/tutorials/ATusing-htaccess.html

It also tells you how to read the apache docs to see which level directives are supported at (hint: Context)

tag-1’s picture

http://httpd.apache.org/docs/mod/mod_alias.html#alias

===

Alias directive

Syntax: Alias URL-path file-path|directory-path
Context: server config, virtual host
Status: Base
Module: mod_alias

===

See the 'Context' line? '.htaccess' isn't listed, so you can't define aliases in per-dir htaccess files.

I realize this isn't giving you your answer but at least it should stop you from spending any more time fighting with the alias approach...

pobster’s picture

If you don't have access to either the httpd or the vhosts file then you won't be able to make new domains like www.sub.domain.com, but you can easily make subdomains like this:

www.domain.com/user1
www.domain.com/user2
www.domain.com/dodgypornsite
www.domain.com/stuffedcatetc

It's dead easy, it only takes a very short script to:

Take a sitename, username, password
mkdir -p sites/%sitename
touch sites/%sitename/settings.php
echo "$db_url = 'mysql://%username:%password@localhost/%sitename';" >> /sites/%sitename/settings.php
echo "$base_url = 'http://www.example.com/%sitename';";" >> /sites/%sitename/settings.php
mysqladmin -u root -ppassword create %sitename
mysqladmin -u root -ppassword GRANT ALL PRIVILEGES ON %sitename.*
mysqladmin -u root -ppassword TO %username@localhost IDENTIFIED BY '%password';
mysqladmin -u root -ppassword flush privileges;
mysql -u %username -p%password %sitename < database/database.mysql

Now I'm not a php programmer :) As you might be able to tell! But I'm not going to do all the hard work for you. It'll only take a little googling to come up with how that should be properly written but tbh, that's the 'general gist' of it!

The *best* thing about doing it like this is that you won't have to worry about adding any extra DNS settings as obviously www.domain.com will resolve to the right IP address regardless of what directory you put after it and that's the MOST important thing!!!

Pobster