Search code examples
dnsa-records

Forward olddomain.com/$ to newdomain.com/$


I've switched domains but want to keep my old links forwarded.

So if someone goes to olddomain.com/lol they would be forwarded to newdomain.com/lol

Can I do this with A record? Whats the best method?


Solution

  • CNAME doesn't work across different domains. You have to use an A record and point it to the IP that hosts your new domain.

    newdomain.com:

    newdomain.com. A 1.2.3.4
    

    olddomain.com:

    ; essentially the IP that newdomain.com is at
    olddomain.com. A 1.2.3.4
    

    Then you need to do something on the webserver hosting newdomain.com to also accept HTTP/1.1 connections for olddomain.com, you can use mod_rewrite or something similar.