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, myapp.domain.com
will forward to one application and any other .domain.com
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?
Within the
<VirtualHost>
you can use aServerName
; this is the directive to tell Apache to handle requests for that particular name. You can also useServerAlias
to specify other domains (and more besides!) that you'd like theVirtualHost
to handle requests for.For example, you can set up your directives like this
The Apache documentation contains several very good examples for most use cases in their documentation (http://httpd.apache.org/docs/2.0/vhosts/examples.html). 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.