Forum Moderators: phranque

Message Too Old, No Replies

Dynamic Subdomains vs Dynamic Virtual Hosts

Looking 4 "dynamic subdomain" solution w/o extra subdirectories

         

thisisshade

9:29 pm on Feb 18, 2008 (gmt 0)

10+ Year Member



Hello everyone,

I apologize if this answer is already out there, however I need a relatively quick solution.

Assuming I have a domain mysite.com with a docroot of /www/htmldocs, when a new user account is created, I want the user to access the site using their username as part of the URL:

users.thisisshade.mysite.com

which still resolves to the original document root. I thought about using the approach outlined in:

[tips-scripts.com...] (and/or)
[tips-scripts.com...]

but since all the subdomains resolve to the document root, creating hundreds of subdirectories just for the sake of a subdomain doesn't seem like a good use of space. Then I thought about having a script dynamically add <VirtualHost> records to an .htaccess file:

<VirtualHost *:80>
ServerName users.thisisshade.mysite.com
ServerAlias www.users.thisisshade.mysite.com
DocumentRoot /www/htmldocs
</VirtualHost>

But this requires a restart of the server, right?

Thanks in advance for your assistance, everyone.

Respectfully, Shade

jdMorgan

11:39 pm on Feb 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<VirtualHost> containers cannot be used in .htaccess, so the restart question is moot.

I presume you'll be using a script to manage the users' access and give meaning to the concept of "individual user space"? If so, then what's needed is just an internal rewrite of the subdomain into a query string name/value pair to be passed to your script (using mod_rewrite).

Please post your best effort at coding this for further discussion. You may wish to try a search for (numerous) previous threads on the subject of passing subdomains to a script, and please take a look at our forum charter [webmasterworld.com] as well.

Thanks,
Jim

thisisshade

1:17 am on Feb 19, 2008 (gmt 0)

10+ Year Member



Thanks for the suggestions, Jim.

resp ¦ shade