How to Change WordPress Site to Use a Totally New URL on the Same Droplet?

October 19, 2018 1.7k views
WordPress Ubuntu 16.04

Hello, please bear with me.

I am rebranding a blog that I run. I’m looking to change my website URL only (from domain1.com to domain2.com), and for it to continue existing on the same droplet.

Right now, I have backed up my droplet as it currently sits. I’ve purchased a new domain (domain2.com) and linked it to the same droplet (there are two domains linked to one droplet now)

The new domain (domain2.com) does not have an SSL certificate, the old domain does (https://domain1.com). Even though it is linked to my droplet, typing it in the URL bar takes me to a generic “Welcome to nginx!” page.

Question 1: Given my current position. What are my options to begin using (domain2.com) as my main wordpress domain? I know that installing a SSL certificate needs to happen. At what point though? I also know that I need to change the URL in the wordpress general settings to (domain2.com), but when do I do that?

I’ve been reading through similar questions online, but am apprehensive in beginning this task without knowing exactly what I’m doing. (domain1.com) is about a year old, with 300 posts, multipleplugins, SSL installed. I hope everything to be switched over to (domain2.com).

Can someone please provide steps for me to follow?

Thank you for your help and time.

4 comments
  • I suggest that you first try and duplicate your droplet and after that play with the new droplet till you get it right. But if you decide to go with your plan on the original droplet then i would suggest also creating offsite backups besides whatever back'up options are offered to you by DO.

    The simple way(one that does not require tech/troubleshooting skills) would be to set'up a new wordpress droplet, link the new domain to it, set'up ssl(the same way you did on the original droplet) and migrate the old wordpress via any of the various methods available(I’ve seen some plugins that can do a simple backup/restore). If successful you can destroy the old droplet.

    Did you install ssl via certbot or another method? If certbot, then this tutorial might be able to help you achieve your goal tho i’d still recommend that you do everything on a new droplet and then migrate the website.

    Droplets are hourly billed as long as they exist less than about 30 days after which they are billed for the full month so you can easily experiment on a new droplet without getting to worry about costs.

    by Hazel Virdó
    In this tutorial, you will use Certbot to obtain a free SSL certificate for Nginx on Ubuntu 16.04 and set up your certificate to renew automatically. This tutorial will use a separate Nginx server block file to maintain the default file as a fallback configuration as intended.
  • Thanks a lot for taking the time. Creating a new droplet, linking the second domain to it, setting up SSL, and moving the contents via plugin seems like the easiest way for me to approach this.

    Do you have insight on 301 redirects? It would be nice to not begin at 0 from an SEO perspective. Both of my domains are registered on Namecheap, which seems to provide a 301 redirect service. Is it as easy as setting my old domain to redirect? Would all the post domains also redirect to the new site?

    Again, much appreciated. These things are insanely nerve wracking for someone who is on shaky feet re. server maintenance.

  • https://stackoverflow.com/questions/6045020/how-to-redirect-to-a-different-domain-using-nginx

    https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-nginx

    The above happens in /etc/nginx/sites-available/olddomain.conf .

    Copy the olddomain.conf from the old droplet to the new(same location as above) and edit it. You can also experiment with a subdomain(new subdomain config file) just to test if the redirected urls work correctly.

    You will also need ssl enabled on the old domain when you move it to the new droplet so a subdomain will be best for testing that as well before you move the old domain to the new droplet.

    Let me know if the above is making any sense. :D

    Also, here’s another tutorial worth reading and about nginx and multiple websites: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

    by Justin Ellingwood
    When using the Nginx web server, server blocks (similar to the virtual hosts in Apache) can be used to encapsulate configuration details and host more than one domain off of a single server. In this guide, we'll discuss how to configure server blocks in Nginx on an Ubuntu...
  • Thanks again for your guidance. Just so I get this right, I’ll list the steps that I’ll be doing and hope you can confirm or correct me here:

    New droplet

    1. Link new url to the new droplet
    2. install wordress, ssl
    3. use a backup/restore plugin to move old wordpress site to new
    4. use WinSCP to find the old droplet’s domain.config file, copy that to the same location of the new droplet
    5. edit the domain config file with: server { servername .mydomain.com; rewrite ^ http://www.adifferentdomain.com$requesturi? permanent; }

    Question1: does the old domain need to be linked to the new droplet along with the new domain? (via DO domains workflow)
    Question2: is setting up server blocks mandatory in my case? does the old website need to be active in any way for redirects to work?

    Thank you for your time

1 Answer

Thanks again for your guidance. Just so I get this right, I’ll list the steps that I’ll be doing and hope you can confirm or correct me here:

  1. New droplet
  2. Link new url to the new droplet
  3. install wordress, ssl
  4. use a backup/restore plugin to move old wordpress site to new
  5. use WinSCP to find the old droplet’s domain.config file, copy that to the same location of the new droplet
  6. edit the domain config file with: server { servername .mydomain.com; rewrite ^ http://www.adifferentdomain.com$requesturi? permanent; }

Question1: does the old domain need to be linked to the new droplet along with the new domain? (via DO domains workflow)
Question2: is setting up server blocks mandatory in my case? does the old website need to be active in any way for redirects to work?

Thank you for your time

Have another answer? Share your knowledge.