Search code examples
urlhttp-redirectdnsforwardingmasking

URL masking/forwarding/redirecting


I have a website hosted on 000webhost and a paid domain was purchased from 1and1. 1and1 offers URL redirecting with HTTP or frame redirect, but I have opted to point the paid domain to 000webhosts name servers.

Currently this works to the point that when I type the paid domain in (www.paiddomain.co.uk), it points me to the correct website (www.freedomain.com). Once on this page any page that is clicked shows up in the address bar as www.freedomain.com/link when what I want is for it to show up as www.paiddomain.com/link.

What's the best way of doing this?


Solution

  • Terminology

    • origin server - the server that provides the original content
    • proxy server - the server that sits in the middle between the client and the origin server

    In your case the origin server is freedomain.com. It sounds like you opted out of a proxy server and just have the DNS pointing to the origin server.

    Reason

    The first page loads fine because it is accessible by two domains. However the HTML content that was delivered has absolute links to the origin server. Therefor when the client clicks on it they are taken directly to the origin server.

    Without a proxy server you have two choices

    1. Get the origin server to generate absolute links to the domain you want.
    2. Get the origin server to generate relative links.

    This depends on how your pages are generated (static html, drupal, wordpress, custom app). But the net effect is that your links will be generated like this:

    <a href="http://www.paiddomain.com/link">absolute URL</a>
    

    or like this:

    <a href="/link">relative URL</a>
    

    If your site uses cookies you will also need to figure generate them for the correct domain.

    For systems that generate an absolute URL they will usually have a variable that stores the "site url", "base url", or similar either in their configuration or in the database.

    With a proxy server

    You can ask your proxy server to translate links (and cookies, etc) from freedomain.com to paiddomain.com. This depends on the proxy server, in apache you would use ProxyPassReverse.

    1and1 is apparently not willing to be your proxy server: http://faq.1and1.com/domains/domain_admin/domain_dest/3.html They are willing to provide a frame (poor bookmarkability), or HTTP redirect (change the URL).