Report this

What is the reason for this report?

How to redirect mydomain.com to linktr.ee/mydomain ?

Posted on September 6, 2023

My main objetive is to redirect mydomain.com to lintr.ee/mydomain. I have my account at linktree all set up. I’ve already bought mydomain.com and set Godaddy’s Name Servers to look for Digitalocean’s DNS for directions. I’ve also used Digitalocean’s DNS to create a “CNAME” entry to redirect WWW to @. But now I’m stuck because an “A” entry will only let me specify an IP or a resource that I own on Digitalocean. What should I do? How do I redirect mydomain.com to my linktree link using Digitalocean DNS config?

PS: this is just a temporary redirect while I create my site



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

While you can use DNS to create an alias with a CNAME record (like making www.mydomain.com point to example.otherdomain.com), DNS by itself doesn’t handle HTTP redirects (like redirecting users who visit mydomain.com to lintr.ee/mydomain). You need a Droplet and a WebService like Apache or Nginx to do that.

Set up a DigitalOcean Droplet:

  • Create a small droplet.
  • Install Nginx on it. If it’s an Ubuntu droplet, you can use:
sudo apt update
sudo apt install nginx

Nginx Configuration:

  • Edit the default Nginx configuration or create a new one. For simplicity, you can edit the default:
sudo nano /etc/nginx/sites-available/default

Remove the current server block and replace with the following:

server {
    listen 80;
    server_name mydomain.com www.mydomain.com;
    
    location / {
        return 301 http://lintr.ee/mydomain;
    }
}

Set A Record:

-   In DigitalOcean's DNS management, set an "A" record for `mydomain.com` (and `www.mydomain.com` if desired) to point to the IP address of the droplet you just set up.

Finalize:

-   Wait for DNS propagation. Depending on various factors, it may take anywhere from a few minutes to 48 hours (usually on the shorter side if it's a new domain).
-   Now, when you visit `mydomain.com`, it should redirect to `lintr.ee/mydomain`.

Note on HTTPS: If you plan to use HTTPS for mydomain.com, you’ll need to set up a certificate (e.g., using Let’s Encrypt) and adjust the Nginx configuration accordingly.

While the above process requires maintaining a droplet, it gives you flexibility. Once you have your website ready, you can reconfigure the Nginx server to serve your website instead of redirecting to Linktree.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.