Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a domain registered, say for example, domain.com I want to be able to send sub.domain.com to a certain page on my server and sub2.domain.com to go to another page. Can anybody tell me how I can get sub.domain.com and sub2.domain.com to resolve in dns? I presume that I have to get some sort of DNS forwarding working so that once the request reaches domain.com, sub.domain.com and sub2.domain.com will be handled by my machine.

share|improve this question

migrated from stackoverflow.com Oct 25 '09 at 21:01

This question came from our site for professional and enthusiast programmers.

2  
I believe this type of questions are best asked on serverfault.com (Stackoverflow is merely about programming). Perhaps someone with more editing rights can move the question for you. –  Abel Oct 25 '09 at 20:58
add comment

3 Answers

Two things to do.

First, since you own domain.com, you are the official registry and DNS site for all subdomains, unless you explicitly configure your DNS to send them elsewhere. Hopefully, your server also hosts the authoritative DNS for your domain, in which case the easiest way to create a subdomain, is to add another A record for it.

For example, you have a DNS configuration with something like this in it:

www IN A 192.168.0.1

And that is what defines www.example.com as the web server for example.com. Now you want to send requests for www.fred.example.com to the same web server. Simples!

www.fred IN A 192.168.0.1

is all that you need. Of course, many books will tell you that you need to set up another zone with its own SOA and set up NS records to point to it, but the fact is that if the only purpose of the subdomain is to run another website, it is easier to do the above.

Now for the second thing, and that is harder for me to explain in detail since you tell us nothing about your web server software. What you need to do is to configure the web server software to handle virtual websites based on virtual domains, often referred to as name-based virtual hosting.

This vhost tutorial for Apache explains what you need to setup in the Apache configuration. For IIS, you can create a virtual host website from the command prompt or you can do it through the GUI.

Note that a name-based virtual host cannot generally be used for SSL secure hosting, although there are ways around the restrictions. If you really need this capability, I suggest that you ask it as a separate question.

share|improve this answer
add comment

You need to make the subdomain resolve to your server and tell your server what to serve for the subdomain.

The exact procedure to change the DNS will depend on your nameserver, but you need to add a CNAME from sub to @.

You then need to add a web site to your web server.

Which web server are you using? Apache? IIS?

share|improve this answer
add comment

you need to configure dns and web server.

dns so that all requests to subdomains will go to domain.com

and web server to dispatch on http host

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.