Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Apache, and I'm trying to set up a subdomain for a virtual host, which then points to a server on a different IP address.

So the virtual host is, I'd like to set up, and point it to

I've consulted some of the answered questions on SO and other sites, but I'm a bit overwhelmed and I don't want to risk wrecking a production site.

share|improve this question
you do this with DNS, not at the webserver level – Smudge Dec 6 '11 at 12:29
also, spend some time creating a test environment. It is time extremely well spent. – alex Dec 6 '11 at 12:48
You are absolutely right. I don't know where my head was at. – Squrler Dec 6 '11 at 12:50
up vote 0 down vote accepted

If you really do want to have resolve to then the only sensible place to do this is in the hosts file on the server. This is either /etc/host (unix like systems) or %SystemRoot%\system32\drivers\etc\hosts for windows systems e.g.    localhost

Be aware though that is the loopback address and is only accessible from the host on which it is defined.

share|improve this answer
I'm sorry, you are absolutely right. As Sam pointed out in a remark to my question, what I was trying to achieve should of course be done on the DNS level. I wasn't thinking. Thanks for answering. – Squrler Dec 6 '11 at 12:51

The best way to do this is using DNS (an A record), however if you really want to do it with apache you could define the virtual host then use mod_proxy to pass the request to the other server. Have a look at for some example

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.