HAProxy community

Redirect to new url but preserve original domain

I have a original.com and wish to redirect to alias.com. How do a redirection and keep the URL in the browser.? Is this even possible?

The only way to achieve a “real” redirection is to use the HTTP 301/302 (and alternatives) issued by the server handling original.com and referring the client (via the Location header) to alias.com.

By “real” redirection I mean one in which the client first contacts the server handling original.com, obtaining the redirect response, terminating the communication with original.com and moving to alias.com. (I.e. the original.com server is not involved anymore in the connections between the browser and alias.com.)


That being said, you could configure the HAProxy on original.com to proxy those requests to the alias.com server (by first changing the Host header); however in this setup the original.com server will always be active, acting as a proxy, between the client and the alias.com server. This implies extra latency, extra costs (if you pay for upload / download on your original.com server’s provider).

(Alternatively you could also serve on original.com an HTML page with an <iframe> element spanning the entire viewport, which loads alias.com. However I would strongly advise against this, as some browsers might interpret this as a security threat, and if you don’t also control alias.com it could even set some HTTP headers pointing to browsers that such behaviour is not allowed.)


The conclusion is that “real” redirects are the best solution.