URL Redirection

Beside email forwarding, hanami offers a userful service for URL redirection so you can redirect your domain/url to another website without the need to maintain your own server.

The process requires create 2 DNS records

Step 1. create cname record to point to our server

This CNAME records will point your domain to our server so we can serve traffic and do URL redirection. simply add a cname record with these values
hostname: @ or blank on your provider
type: cname
value: forward.hanami.run
Example, in this screen I used CloudFlare to define CNAME record

Step 2. create txt record for redirect URL

This records will let us know where to redirect to.
Add a TXT record with these value TYPE: TXT
Hostname: hanami-forward
Value: the-url-to-redirect-to
Example, in this screen I used CloudFlare to define TXT record

How URL redirection works

Once a request hit our service, we check the domain name of request, fetch the `hanami-forward` TXT record. If we found one, we will do a 302 redirect to the-url-in-txt-record/the-path-in-your-request

As an example, let's say I have domain magicmail.run and this TXT records

Type Hostname Value
TXT @ hanami.run

Then if someone visit https://magicmail.run they will be redirected to https://hanami.run. If they visit a specific URL such as https://magicmail.run/docs then we will redirect to this full url https://hanami.run/docs

Using subdomain

If you want to redirect a subdomain let's say blog.domain.com you need to create DNS records on sub domain level as below:

Type Hostname Value
CNAME blog forward.hanami.run
TXT blog personal-site.com

Now once you go to blog.domain.com, you will be redirected to personal-site.com