Web Hosting Talk







View Full Version : Setup Subdomains


Voodoo Web
06-27-2001, 05:59 PM
I want to know how do you setup the subdomains for your virtual hosting clients.
I don't use a well-known control panel so I'm interested in a general configuration for Apache. I know I can add every subdomain as VirtualHost to the httpd.conf but is there not a simpler solution?

- domi

ServerRackNet
06-29-2001, 10:57 AM
If you're not using a web panel, adding the subdomains as VirtualHost to httpd.conf is more or less the way to do it. You can use a database to do it, but it requires a lot of up front programming, so you may want to stick to your original idea.

Voodoo Web
07-01-2001, 04:57 PM
I'm creating my own control panel for my clients and primary I don't want a script that modifies the httpd.conf. Because if there goes something wrong it could stop the whole webserver.
Now I'm looking for someone who knows a method to realise subdomains with mod_rewrite, mod_vhost_alias or an external file.
Can somebody help me?

Thanks

- domi

Madman2020
07-01-2001, 11:37 PM
Well you can do a rewrite rule in an .htaccess, but that would just point the subdomain somewhere. If you want a inidividual site for your subdomain you have to modify httpd.conf. Otherwise you can always use iPlanet... lol

Voodoo Web
07-02-2001, 01:01 PM
This afternoon I had some time to look into my problem again.
Finaly I found a solution that met my criteria.
I will post it here, maybe it is helpful for someone else.

Put the lines below in the VirtualHost section of your httpd.conf:

RewriteEngine On
RewriteMap subdomain txt:/usr/www/yourdomain.com/yourdomain.map
RewriteCond %{HTTP_HOST} ^(.*)\.yourdomain\.com
RewriteCond !/icons/
RewriteRule ^/(.*) ${subdomain:%1|/usr/www/yourdomain.com/public_html}/$1


The RewriteMap-File should look like the lines below:

#
# subdomain mapping file
#

images /usr/www/yourdomain.com/public_html/images
img /usr/www/yourdomain.com/public_html/images
forum /usr/www/yourdomain.com/public_html/board
statistics /usr/www/yourdomain.com/public_html/stats
www.images /usr/www/yourdomain.com/public_html/images


This works fine, I didn't found any problems until now.


- domi

Starhost
07-22-2002, 12:45 PM
Could you please explain this a little further. Because what does it exactly do? Rewrite the document root?

Voodoo Web
07-24-2002, 03:37 AM
Yes it rewrites the document root based on the subdomain used. If the used subdomain is not configured it use the standard document root from the virtual host.
The best thing is the FrontPage Extensions and logging still works.

- dom

genedavinci
09-23-2002, 09:03 PM
hi. i am a total newbies in webhosting and i am very interested in getting a sub domain running on my apache. so, if say i would like to add a www.newsubdomain.mysite.com, do i simply add

VirtualHost section of my httpd.conf:


RewriteEngine On
RewriteMap subdomain txt:/usr/www/mysite.com/mysite.map
RewriteCond %{HTTP_HOST} ^(.*)\.mysite.com\.com
RewriteCond !/icons/
RewriteRule ^/(.*) ${subdomain:%1|/usr/www/mysite.com/public_html}/$1


my mysite.map


#
# subdomain mapping file
#

newsubdomain /usr/www/yourdomain.com/public_html/mynewfolder

genedavinci
09-23-2002, 09:04 PM
also, i have read somewhere that i will require a wildcard facility before i can have subdomains....

may i ask, what is a wildcard facility?


thanks.

erikcw
10-24-2004, 11:23 PM
For wildcard subdomains, just add
* A 123.123.123.123 [your ip]
in your DNS zone - give it a little while to propogate and you should be in business....