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

Without giving all the details, I'm trying to set up (via apache) two web applications that will be served from the same (internal development) server. Currently I have two VirtualHost directives and the two applications running on different ports. Instead, I'd like to have the URL determine which application is used, so, for example, will forward to one application and any other will go to the other. Setting up the internal DNS to take care of that piece isn't a problem. But I'm not very familiar with apache, what's the best way to accomplish this?

share|improve this question
up vote 3 down vote accepted

Within the <VirtualHost> you can use a ServerName; this is the directive to tell Apache to handle requests for that particular name. You can also use ServerAlias to specify other domains (and more besides!) that you'd like the VirtualHost to handle requests for.

For example, you can set up your directives like this

<VirtualHost ...>
    #Handle webapp1 in here

<VirtualHost ....>
    ServerAlias *
    #Handle webapp2 in here

The Apache documentation contains several very good examples for most use cases in their documentation ( You may also be interested in their "default" catchall halfway down the page, which is basically a catchall for any virtual host requests that aren't matched by previous directives.

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.