How do I properly redirect aliases/variations of my domain to the main tld I want to use?

I have two of the same domains with the most common TLDs in my country, (primary domain to be redirected/forwarded to) and

The domains I have purchased are from GoDaddy, and I have already set their name servers to Digital Oceans’ NS1, NS2 and NS3 servers on the GoDaddy domain control panel.

Both domains are now setup on my Digital Ocean account and pointed at my Ubuntu 16.04 LAMP droplet. I have setup a simple CNAME record on both domains to catch the www subdomain. The droplet can be successfully accessed through a web browser via both domain names. The CNAME records however, seems to only work on the .ca domain. The .com domain still displays a blank page instead of the content that I have residing inside of the var/www/html/ like the .ca domain does as it should (I suspect this just the time that it can take for this kind of server stuff to be done).

Now, I have looked around quite a bit and tried a few things including the Forwarding Panel in the DNS settings for GoDaddys’ domain control panel, and a tutorial here on DigitalOcean that talks about Apache and Nginx Redirects, however it only works for a single page, not the entire website, the former didn’t work while the latter isn’t exactly what I am looking for (almost is). The end result I am looking for is to properly and securely setup a 301 redirect from to the primary domain, including all the pages.

If there is more information needed, let me know. Thanks a lot in advance! I am really liking the DigitalOcean services and community from the short few days I have been here. :)

Submit an answer

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!

Sign In or Sign Up to Answer

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.

How? Please

This guide will walk you through setting up your redirect.