This guide explains how to configure your domain to redirect to the desired target using the DNS redirect service.
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.
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:
permanent-redirect.net
- Redirects with status code 301 (Moved Permanently).temporary-redirect.net
- Redirects with status code 307 (Temporary Redirect).The redirect domain is cached for the duration of the TTL
value of the CNAME
record.
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
.
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:
A
record pointing to IP address 3.250.250.65
for the apex domain.@
as shown above.
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
.
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
.
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.
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.
The source code is available under the MIT license at jasny/dns-redirect on GitHub.
This is a free service by Jasny.