DNS Redirect

This guide explains how to configure your domain to redirect to the desired target using the DNS redirect service.

How It Works

The redirect service allows you to configure a domain to automatically redirect to a new destination based on CNAME records. By adding a CNAME record to your DNS, you can specify the target domain for redirection and indicate the type of HTTP status code to be used.

Configure your domain

Add a CNAME record pointing from your desired domain to the target domain you want to redirect to, followed by one of the redirect domains:

The redirect domain is cached for the duration of the TTL value of the CNAME record.

Example

Suppose you want to redirect your .net domain (www.example.net) to your .com domain (www.example.com). You should create CNAME record for www.example.net that points to www.example.com.permanent-redirect.net.

Apex DNS record

The domain apex, is the DNS record without a subdomain (eg example.com). This can't be a CNAME record, because it must be an A record. To configure a redirect for your apex domain:

Example

Suppose you want to redirect example.net to example.com. You should create an A record for example.net to 3.250.250.65 and a CNAME record for @.example.net that points to example.com.permanent-redirect.net.

Visiting your domain

When someone visits your domain, they will automatically be redirected to the specified target domain according to the CNAME record and the corresponding HTTP status code.

The URL path and query are unchanged for the redirect. Example; https://example.com/hello?planet=world will redirect to https://example.net/hello?planet=world.

Automatic HTTPS support

The redirect service will not modify the schema (http or https) of the request. For HTTPS, a certificate is automatically obtained using Let's Encrypt on the first request.

Host your own service

This service is also available as Docker image. It's a lightweight application written in Go that can handle many requests using minimal resources.

docker run -d \
  -e REDIRECT_DOMAIN_301=redirect.example.com \
  -p 80:80 -p 443:443 \
  -v certs:/var/app/certs \
  jasny/dns-redirect

Please visit the project on Docker Hub for more information.

Source code

The source code is available under the MIT license at jasny/dns-redirect on GitHub.

Author

This is a free service by Jasny.