ruby-on-railsdnscross-domainsubdomainwhite-labelling

Forward a domain but keep URL


I'd like to send http://app.client-domain.com/ to my Heroku-hosted Rails app at http://www.my-domain.com/.

From research it looks like this would be relatively straightforward (with domain record redirects/forwards like A, MX, CName, etc.)

However, I don't want http://app.client-domain.com/ to just forward the browser to http://www.my-domain.com... I want it to appear that the user is still on http://app.client-domain.com.

For example, a request to:

http://app.other-domain.com/user/4

would be serving data from:

http://www.my-domain.com/user/4

... but the URL would remain:

http://app.other-domain.com/user/4

Likewise, if a user is sent (via the app) to a new address within the app (like /products/4), the scheme above would be maintained. It would truly look like the app lived at

http://app.other-domain.com/

Is this possible?


Solution

  • It is possible. There are two main methods to achieve something like this.

    The preferred method would be for the client to use a DNS CNAME that points app.client-domain.com to www.my-domain.com. Your heroku app, would then have to be configured with the domain app.client-domain.com. It should also be configured to not redirect to "primary" domain.

    The more problematic way to solve this, is to set up a webserver for app.client-domain.com that serves a webpage with frames, where www.my-domain.com is then loaded in a frame.

    The CNAME approach is by far the preferred way. Using frames gives issues with SSL, and some sites might try to escape being in frames, and will likely also cause PCI compliance issues if you are using payment gateways.