Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

Configuring sub-domains

How to configure a sub-domain to also work with www

8:16 pm on Sep 30, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 7, 2002
votes: 0


Im having a problem because I dont know how can I configure my server so all the sub-domains work with www also...

Lets say I have "test.misite.com" I want the sub-domain to also work with "www.test.misite.com"

Im working on a Linux OS with Apache version 1.3.24


12:02 am on Oct 1, 2002 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 12, 2002
votes: 0

Two issues here. First is DNS, and second is virtual hosts.

www.test.mysite.com needs to point to the same ip as test.mysite.com does. How you accomplish this depends on whether you run your own name server, if so which one it is, and if not how your ISP allows you do modify DNS data.

Then you need to configure your virtual hosts on Apache. How you do this is quite variable depending on what you are doing. If you have a different IP for each distinct site you are hosting, then do something like:

ServerAdmin webmaster@mysite.com
DocumentRoot /dir/with/mysite/content/
ServerName www.mysite.com

ServerAdmin webmaster@test.mysite.com
DocumentRoot /dir/with/test.mysite/content/
ServerName www.test.mysite.com

This will make Apache serve different content based on which IP you connect on. Apache won't care if you hit that IP by calling it test.mysite.com or www.test.mysite.com.

If you don't have multiple IPs at your disposal, you can use NameVirtualHost. I'm not sure if you have to define multiple NameVirtualHost sections, one for each name, or whether you can list multiple names. I don't have any NameVirtualHost sections in my own config right now, because they are incompatible with SSL, and all my domains have SSL support.