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

first time here at Server Fault, and I apologize in advance that this domain stuff is not really my strength. Any and all suggestions are much appreciated. I am completely lost and incredibly tired!

I've inherited an incredibly convoluted system from my predecessor, and I'm trying to find a way to solve it - or I need to be told that it just isn't possible.

  • I've got an old site on ServerA (some kind of Linux distribution), with the domain
  • There is a new site sitting on ServerB (Ubuntu), with the intention of having to serve it in the future (it is replacing the old site)
  • ServerA also has a web app that is currently in use by other departments within the company (accessible at

The goal: To have and all extensions of this domain name (sub-domains, URL's etc.) serve the new site on ServerB. BUT, the URL must serve the Web App on ServerA.

The Catch: The ServerA is a shared server with a hosting company with VERY limiting restrictions in place - I cannot adjust DNS settings (apart from Name servers - but cannot set A records or anything, I have full access to ServerB to do as I wish). Therefore the web-app MUST be served from and not from a sub-domain or anything. These limitations make migrating the web-app from Server A to Server B rather undesirable, AND this web-app will be replaced in the near future, so it isn't worth the effort right now.

Therefore, ultimately I will want 1 domain name to resolve to Server B's IP address most of the time, but in the event that the URL is, it should resolve to Server A's IP.

Note: The domain names don't, technically, have to resolve to one IP or another - but ultimately the URL's must stay consistent

Some things I have tried:

  • I've looked into mod_rewrite and .htaccess to try and achieve this effect, but it doesn't look like it's going to work for me - but I may have done it wrong (On Server B, I just checked if the request URI was /web-app/ and tried to serve the /web-app/ folder on Server A)
  • I do have the ability to modify the name servers on both servers
  • I am not able to make a sub domain on Server A that points back to Server A (I assume because the hosting company's servers use the URL to determine what site the serve). I figured this could be good as I'd could set an A record on Server B to point to the web app on Server A - but alas, Server A requires

If there is any more information I can give, please let me know. I need a nudge in the right direction, ideas or a solution.

share|improve this question
up vote 1 down vote accepted

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
  2. Set the fully qualified domain name on server B to
  3. Add use mod rewrite or whatever you like to redirect traffic from to

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, 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 as the ServerName and it sounds like you can't change it, your only option is to create a new server name.

share|improve this answer
Hi jpgeek. In this scenario, what would I do with my DNS settings? Should I have point to server B (whose fqdn will be Or do I keep it pointing at server A? Would this not mean that users would have to go to to reach the new site (server B)? I'm afraid I don't fully understand this, sorry! Could you please clarify? – Jace Dec 11 '12 at 1:45
Hi jpgeek, I did solve this issue using the www subdomain and some nasty htaccess redirects on Server A to Server B. I'm not sure if this is exactly what you suggested, but your answer inspired this direction, and as there is no better answer to date, I will mark your answer as correct. Thanks for your help! – Jace Dec 12 '12 at 5:06

You may also consider this option:

Configure your webserver on serverB to behave as a reverse proxy that hits ServerA for the specific location /web-app/ and that loads other locations content from serverB.

The config is pretty much easy and straight forward, you will find many samples available.

share|improve this answer
Hi m0ntassar, this sounds great. However, I've done a bit of reading into Reverse Proxies since reading your answer as I've never done it before and from what I've read, I'm not 100% sure this will work in my case, unless I'm misunderstood (which is likely)... does this mean that continues to point to ServerA (which remains untouched throughout this process) and the ProxyPassReverse settings would be on ServerB? – Jace Dec 10 '12 at 6:07
ProxyPassReverse should sit on the server on which points. The solution i provided you supopses that you alreadey repaced site on serverA by site sitting on the new serverB – m0ntassar Dec 10 '12 at 8:20
Oh ok, unfortunately that won't work in this case due to the limitations of ServerA so I will not be able to replace the site. I must keep the contents of ServerA as it is, but serve all requests from ServerB, unless the uri is /web-app/. A very confusing and unfortunate situation. But thanks for the suggestion! – Jace Dec 10 '12 at 9:52

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.