Search code examples
apacheweb-servicesiiswebapache-tomee

Infer a parameter in a WEB app depending on the URL


I'm developing a database backed web-app. I will be providing the same basic services to several branches of the same company.

Right now I have an Apache server with virtual servers and a resource server for reporting.

branch1.mycompany.com
branch2.mycompany.com
resources.mycompany.com

So basically when I call resources from the site I pass the site as a parameter.

branch1.mycompany.com -> resources.mycompany.com?branch=1&parameter=1
branch2.mycompany.com -> resources.mycompany.com?branch=2&parameter=1

Even with two branches there is a problem trying to keep up with updating both sites and now, I'm going to be implementing this scheme for seven sites.

So my question is this: Is there a way I can make a IIS or TomEE web-app with the following features?

  • I want to still allow each branch to access trough its URL
  • Even when there are 7 URLs; all of them will be pointing to the same web-app
  • Depending on the URL, is there a way the site parameter can be inferred or calculated so I can call the right resource or web service?
  • The user should never realize they are accessing a common web-app. (i.e. should not be redirected to web-app.mycompany.com?site=1.)

Solution

  • Tomcat (so tomee) has now a rewrite valve which is close to httpd mod_rewrite, this can surely solve that smoothly. I assume IIS has it as well but don't know it that much. Trick is to reverse proxy the requests.