DEV Community

Cover image for How to Redirect a domain only using DNS records
Wildan Mubarok
Wildan Mubarok

Posted on • Updated on • Originally published at


How to Redirect a domain only using DNS records

At some point in time to want to move your website to a new domain address but don't want people with existing URL links to your old domain to find your content is no longer found, so then you need to set up a redirect link.

I thought this was easy, but turns out it isn't. You need a separate server for that. Who would want to purchase additional bucks just to set up a server to redirect links?

So let's meet, a simple redirect service.

All you need to do to use this service is to add CNAME and some TXT records, like this:     IN    CNAME   IN    TXT     forward-domain=*
Enter fullscreen mode Exit fullscreen mode

This will redirect all links from to You can also redirect other domains, just change the forward-domain= part.

In case you want to redirect a root or apex domain, you can't do that with CNAME, so you can use an A record that directly bind to the IP address of this service:     IN    A   IN    TXT     forward-domain=*
Enter fullscreen mode Exit fullscreen mode

That's it! this will redirect all links from to Note the * part? it means also forward URL paths and GET query data.

What about the email? It is used to signing HTTPS certificates from Let's Encrypt. This should be your valid public email. HTTPS redirection would not work without it.

This is all you need to be able to set up domain redirection of your old domain. No coding required, no registration required, completely free and anonymous. You can also see the GitHub repo since it's an open-source project anyway.

EDIT 2021-09-21: This post is updated for v2.0 changes

Top comments (3)

cicirello profile image
Vincent A. Cicirello

You can probably do this directly with your domain provider without involving a 3rd party. For example, Google Domains has domain redirection. I imagine most domain providers support that. Is there an advantage to using this forwarddomain service instead of your domain provider?

willnode profile image
Wildan Mubarok • Edited

Automation. I mean if your domain nameserver is not set to its own domain providers, you'll lose this feature, there are many cases why you want to manage your own DNS or giving it to third-party (CloudFlare or something else) and it happens to my situation a lot.

wpsyed profile image
Syed Saadullah Shah

I appreciate !

Here is a post you might want to check out:

Regex for lazy developers

regex for lazy devs

Sorry for the callout πŸ˜†