Single domain name potentially resolving to multiple servers

There are a bunch of issues here which makes it not quite as easy as it should be.

First, I think the best way to handle this is:

  1. If you cannot change the settings on server A, leave it as www.somedomain.com.
  2. Set the fully qualified domain name on server B to www2.somedomain.com.
  3. Add use mod rewrite or whatever you like to redirect traffic from www2.somedomain.com/web-app to www.somedomain.com/web-app.

Now for the details.

The DNS servers resolve the fqdn to the ip address. They cannot help you with anything below that (such as the path). DNS requests don't even contain the request path.

On a shared server, it is almost certainly using HTTP 1.1 and name based virtual hosts. In other words, the box has one IP address, and it looks at the HOST header in the request to determine which site to serve. Ergo, if you do an IP address based redirect, Server A will just get an HTTP request to 123.123.123.123/web-app/foo, and having a gajillion sites on that server it will have no idea what to do with it.

Since your servers have different content (at least for one path), and you cannot use IP address based redirects, you will have to use different fqdn's to distinguish them.

Since the old site is probably already set up with www.somedomain.com as the ServerName and it sounds like you can't change it, your only option is to create a new server name.