How to forward domain to with NS at Digital Ocean?

Posted February 5, 2019 1.5k views
DigitalOceanDNSUbuntu 18.04

Running wordpress Ubuntu, installed via Serverpilot (nginx reverse proxy apache)

I have 2 domains, NS are with DO, NS with another host, but pointing to DO servers. I need to point to domain2,

I added both domains via serverpilot, so both domain1 & domain2 show the same exact website, and each domain can be used to access the site.

I think I may have set this up a little wonky, but I can’t figure out how to get domain1 to show domain 2 site.

Thanks in advance, and if I missed anything or my explanation doesn’t make any sense let me now.

Thank yoU!

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.

Submit an Answer
3 answers


So if anyone else is having this problem it can be fixed real easy via editing the wp-config.php file

I did what @jarland had said, but it was causing all sorts of redirects. Serverpilot creates SPREQUESTURL for site url and home. So all I had to do was change that to the domain I wanted the website to show,, and now both and both show -

Hope it helps someone else!

Hey friend,

Given that your setup is Apache reverse proxied by Nginx, this may actually be quite easy. At least, I’m hoping it is. Try creating a “.htaccess” file in the document root for domain1 with this in it:

RewriteEngine ON
RewriteRule ^(.*)$ https://domain2.tld/$1 [R=301,L]

Replace “domain2.tld” with your domain, and adjust the https if you do not use SSL. If you already have a .htaccess there, rename it to something like “.htaccess.old” to keep it but get it out of the way.


Thank you Jarland, so I think this is working, the problem I came across is that I am currently running wordpress, so there are some htaccess items listed already. I tried to add this to the current htaccess, it gave me an error with too many redirects. Then I created just this file and I think it worked, but I fear I may be missing some of the needed listed items in the htaccess file below? I tried to arrange some of them, but my knowledge on what the wordpress htaccess file is doing is a bit limited.

BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUEST
RewriteRule . /index.php [L]

END WordPress