I want to know how I can accomplish this:

new.com --> old.com (displaying new.com in the address bar)


A user of sub.old.com wants to buy a domain (new.com) for his/her blog. But she wants to display new.com in the address bar instead of the sub.old.com .

It will point to the subdomain.

What do I need to do? Do I only need to add a record for new.com or something on old.com as well?

And lastly, could It be done with nginx for old.com instead of going to the control panel of my domain host?

  • 1
    What exactly are you trying to accomplish? Do you just want to redirect new.com to the same IP as old.com? – mzhaase Sep 9 '16 at 15:03
  • @mzhaase Edited the question. – Doadc Sep 9 '16 at 15:07

In the general case, if it were possible to have a person actually be on one domain but show a different domain in the URL, this would be a pretty severe security problem.

The closest you are going to get, in the case where you actually have control over both domains, is to set up an iframe from the host what want to show in the browser and bring in the content from the sub-domain.

I know GoDaddy offered essentially this and called it "Forwarding" the site.

It would be better to have sub.old.com send 301 Permanent Redirect to the relevant urls on new.com and let it get sorted out by search engines if they are afraid of whatever SEO loss there might be.



  1. Enter an A and/or AAAA DNS record on new.com pointing to the server of sub.old.com.
  2. Configure nginx to listen for requests on that domain.

Nginx config:

server {
    listen 80;
    listen [::]:80;

    root /var/www/same/as/sub.old.com;
    index index.html index.htm;

    server_name new.com;

    location / {
            try_files $uri $uri/ =404;


Machines on a network cannot establish connections with domains, only IP-addresses. As such, DNS servers exist to translate domains to IPs. If you want two or more domains to direct to the same server, you have to set the A (IPv4) and/or AAAA (IPv6) records of the domains to point to the same server. This is the only way both domains direct to the same webserver. For web purposes, both domains now essentially behave the same. Other DNS records can still be different.

The other way of redirecting traffic is to have both domains point at two different webservers, and new.com has an index page that redirects to sub.old.com, but then the URL would change, because it actually redirected you to another domain. It has to, since the new.com server actually does not host the content, sub.old.com does. Both domains do not behave the same in this scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.