Apache httpd Redirecting URL based upon Server Name

apache-2.2mod-proxymod-rewrite

We have a Jira and a Confluence system at my work. Both are running on the same servers. The actual URL to access Jira and Confluence are:

http://foauslxapp05:8080/jira
http;//foauslxapp05:8090/confluence

or with the fully qualified host name:

http://foauslxapp05.foservices.corp:8080/jira
http://foauslxapp05.foservices.corp:8090/confluence

To simplify everything, I've setup a proxy rule to allow users to do this:

http://foauslxapp05/jira  <-- Accessing Jira
http://foauslxapp06/wiki  <-- Accessing Confluence

Our techs have created pair of server aliases for foauslxapp05, so that:

http://jira/jira     <-- Accessing Jira
http://jira.foservices.corp/jira  <-- Accessing Jira
http://wiki/wiki     <-- Accessing Confluence
http://wiki.foservices.corp/wiki  <-- Accessing Confluence

What I'd really like to do is take this to the next step:

http://jira    <-- Accessing Jira
http://jira.foservices.corp  <-- Accessing Jira
http://wiki    <-- Accessing Confluence
http://wiki.foservices.copr  <-- Accessing Confluence

The problem, of course, is that the DNS names jira and wiki are merely DNS aliases for foauslxapp05. I need to detect the URL that the user entered (i.e. what host the user requested), then based upon that URL, I need to redirect the user to the correct application.

I'm not even too sure what I should be looking at: Is this VirtualHost? mod_rewrite? mod_proxy? Or, is this something else entirely. I can't imagine something like this being too difficult to do. Unfortunately, I'm just not too familiar with Apache httpd.

Best Answer

You can do this by using the ServerAlias variable in your virtual host configuration, this configuration item can support a list of server names/aliases:

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

Related Topic