Report this

What is the reason for this report?

Redirecting multiple domains to one domain

Posted on April 11, 2020

I have three domains. Domain 1, 2 and 3.

I want to redirect domain 2 and 3 to go to domain 1.

I have a droplet setup, and everything works fine for domain one. Site loads.

Current setup to redirect domain 2 and 3 to one:

DNS Two A records for each, pointing to the domain 1 droplet. A record with WWW and one without.

NGINX Setup:

server {
    listen 80;
    server_name www.domain3.com domain3.com;
    return 301 https://www.domain1.com$request_uri;
}

server {
    listen 80;
    server_name www.domain2.com domain2.com;
    return 301 https://www.domain1.com$request_uri;
}


server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name domain1.com;
    root /home/forge/domain1.com/public;

It seems to be working for me. For others, it’s not working when links are sent to them. Sometimes it works if they re-type it in their browser. Eventually, after a while, they seem to all work though. A few times I’ve noticed it loads the site, but isn’t changing the URL.

Is this just taking time to propagate? Or is this setup incorrect but works in some cases.



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.

Hi there @nmarketti,

It sounds like that it might be due to browser cache.

What happens if you try with curl for example? So it would look something like this:

  1. curl -IL http://domain2.com

Let me know how it goes. Regards, Bobby

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.