How to redirect to another domain using DNS

Introduction

One would like to redirect one domain to another for many reasons. Maybe you merged your online store at shop.yourdomain.com under www.yourdomain.com/shop. And you still want the existing backlinks to work and take the visitors to the correct page even though the domain has changed.

Or maybe you rebranded your website from www.old-long-domain-name.info to www.new-domain.com and would like all old pages and files to redirect to the new domain. For example, www.old-long-domain-name.info/very-good-product should redirect to www.new-domain.com/very-good-product. If this redirect is not in place, you might lose out on a lot of business.

Redirecting an old domain to a new domain

Can DNS do domain redirects?

Unfortunately, DNS (Domain Name System) alone cannot do any domain-level redirects. It is used to translate a domain name (human-readable format example.com) into an IP address (a numeric format like 8.8.8.8) that the browser can handle.

With DNS, you are able to implement a CNAME record that points domain-a.com to domain-b.com. (DNS can do many other things besides CNAME as well, but they are not relevant to this post.) What this does is that when you type domain-a.com in the URL bar of the browser, it will resolve the domain-b IP and try to access the web server of domain-b.com.

Without explicitly configuring the web server to also serve content for both domains, it likely will not work. Additionally, the domain in the URL bar will stay as domain-a.com, thus not really redirecting the user.

Incidentally, to forward one domain to another domain you do need some kind of a web server that does the redirection for you.

There are some web host providers that have implemented their own support for doing HTTP-based under their DNS configuration views. They have a web server in the background that does the redirection for you.

However, the problem is that they do not support HTTPS traffic for this. Most browsers default to HTTPS and when your redirect does not support it, the user does not get redirected.

Providers with HTTP (no HTTPS) redirect support

If you feel like taking on the web browsers and decide not to be HTTPS-first (bad idea), there are some options from the main hosting providers who can do HTTP-based redirects.

GoDaddy

GoDaddy lets you redirect your domain but only with HTTP. They explicitly mention in the help center article that HTTPS can only be enabled for the destination URL.

GoDaddy redirect not working with HTTPS

For HTTPS-enabled redirects using GoDaddy, please look at our in-depth guide that explains everything about it.

WPEngine

WPEngine also lets you redirect the domain like GoDaddy. But also it does not support source HTTPS as mentioned in their support article.

Bluehost

Bluehost is just like GoDaddy and WPEngine where it supports redirects, but only HTTP-based ones. Read more in their support article.

DreamHost

DreamHost does actually have support for redirecting a domain, but only if you have an active hosting plan. According to their support article, you would also have to configure your SSL certificates yourself for it to work.

DreamHost domain redirect

HostGator

HostGator does have a way to do URL redirection, but it lacks the possibility of having source HTTPS.

Namecheap

Like many of the previous options, Namecheap has support for HTTPS only if you have an active hosting plan and you set up the web server configuration yourself. Without a hosting plan, you are limited to HTTP-only redirects.

Namecheap HTTP only redirects

For HTTPS-enabled redirects using Namecheap, please look at our in-depth guide that explains everything about it.

Hostinger

Hostinger does provide a way to redirect a domain, but it has no simple support for HTTPS and you have to configure it yourself by following a technical tutorial. This means that if you don’t feel fully comfortable with technicalities like this, it won’t be trivial.

Additionally, you would have to be a Hostinger customer. It is not super likely as Hostinger has a market share of around 1%.

Hostinger redirection creation

For HTTPS-enabled redirects using Namecheap, please look at our in-depth guide that explains everything about it.

Options for redirects with HTTPS

Below are some examples of how you could make domain redirects work with technical tools. Some of them include changing configuration files or even deploying full-blown applications to cloud providers so that the redirects are properly done.

If you are not feeling up to the task, scroll past the technical options and take a look at the Domain Forward section.

Configure the web server at your host – technical

If you are already using a web host for your domain then you can probably configure rules for the webserver to direct the traffic for you. This requires technical know-how and keeping a subscription at the host.

Redirecting a Domain with Nginx

Nginx (pronounced “engine X”) is a high-performance web server that is known for its stability, rich feature set, and low resource consumption.

Here are the steps to redirect a domain using Nginx:

  1. Access Nginx configuration file: You first need to access the Nginx configuration file for the website you wish to redirect. This file is typically located in the /etc/nginx/sites-available/ directory. For instance, if your site’s name is example.com, the configuration file would be /etc/nginx/sites-available/example.com.
  2. Modify Nginx configuration file: Open the file with a text editor. In the server block of your site, add the following configuration listed below.
  3. Test your configuration: After saving your changes, it’s important to verify that your new configuration doesn’t have any syntax errors. You can do this by running sudo nginx -t. If your configuration is correct, you’ll see a message that the test is successful.
  4. Reload Nginx: Finally, you need to reload Nginx for the changes to take effect. This can be done with the command sudo service nginx reload.
server {
    listen 80;
    server_name oldsite.com www.oldsite.com;
    location / {
        return 301 $scheme://newsite.com$request_uri;
    }
}

This configuration will redirect all traffic from oldsite.com and www.oldsite.com to newsite.com. The 301 return code signifies a permanent redirect.

Redirecting a Domain with Apache

Apache is another popular, open-source web server. It’s renowned for its power, flexibility, and support for a wide range of modules.

Here are the steps to redirect a domain using Apache:

  1. Access Apache configuration file: You’ll need to access the Apache configuration file for the site you want to redirect. This is usually located in the /etc/apache2/sites-available/ directory. For example, if your site’s name is example.com, the configuration file would be /etc/apache2/sites-available/example.com.conf.
  2. Modify Apache configuration file: Open the file with a text editor. In the VirtualHost block of your site, add the following configuration listed below.
  3. Test your configuration: Just like with Nginx, it’s important to verify your new configuration. This can be done by running sudo apachectl configtest. If your configuration is correct, you’ll see a message that the syntax is OK.
  4. Reload Apache: To make your changes live, you’ll need to reload Apache. This can be done with the command sudo service apache2 reload.
<VirtualHost *:80>
    ServerName oldsite.com
    ServerAlias www.oldsite.com
    Redirect permanent / http://newsite.com/
</VirtualHost>

This configuration will permanently redirect all traffic from oldsite.com and www.oldsite.com to newsite.com.

Cloud provider proprietary tools – technical

Microsoft Azure has a method to redirect a domain using Azure Front Door. You can read more from the docs here. The only issue is that you need to still configure DNS settings and also get your hands dirty in the Azure development portal. And the pricing is either 35$/month for the standard or 330$/month for the premium package.

Azure front door domain redirection

The Google Cloud Platform also has a way to do it with its proprietary tools. One of the solutions is to use the Cloud Load Balancer. You can set up a Load Balancer and configure it in the GCP portal. You can read more in their developer docs here. The pricing is around 18$/month + additional cost per rule if you have a lot of custom rules.

Google cloud URL redirect

Amazon has similar options as Azure and GCP. You can set up a Load Balancer to do the domain forwarding if you are willing to do some technical configuration. You can read more in their support article here.

AWS URL redirect

Cloud Functions, lambdas, etc – technical

There are a lot of budget-friendly methods to redirect a domain. There are usually “serverless” methods where you do not need a full-fledged server running somewhere, but you only pay per use. For smaller and medium-sized websites, this is a great option. The only thing is that even though it is getting cheaper, it is also getting more technically advanced.

Domain Forward – the simplest way

Domain Forward makes it very easy to configure your redirects. It’s as close as it gets to just doing it using only DNS. All you have to do is configure your source domain and destination domain, set up the DNS entry for the source domain, and you’re done. Domain Forward will take care of the infrastructure, the HTTPS setup, and the redirects themselves.

Go check out our Domain Forward quick start guide to see how it can be done.

Conclusion

There are many different reasons and use cases for redirecting traffic from one domain or URL to another. There are also many different technical and non-technical solutions that can be used to do this. It all comes down to your technical competence and your budget. Additionally, the complexity level of your redirects can decide which solution makes the most sense to use.

If you are not sure which option to choose, you can reach out to us and we’ll try to do our best to help you with your setup. Be it using Domain Forward or some other tool.

administrator