Search code examples
wordpressurl

Move Wordpress site to new domain URL without moving files/server?


I was asked by a friend if I could help figure out how to move their Wordpress site to a new domain. I'm not a Wordpress developer, so I'm hesitant to do something that could bring their website down.

My friend has an old domain with a server (web hotel) currently hosting the site, and has acquired a new domain they wish to use for the site. However, the new domain is not connected to a web hotel.

Is it possible to change the site URL of a Wordpress site to a new domain, while keeping the files on a server connected to the old domain?

If the answer is Yes, are these the right steps to take:

  1. Configure the new domain with the registrar to set up DNS, www-forwarding etc.
  2. In WP-admin under Settings-General: Change "Site Address" to new domain, keep "Wordpress Address" to old domain
  3. Find and rewrite any hardcoded URLs pointing to the old domain (anything to look for on the backend?)
  4. Configure the old domain to redirect to new domain
  5. ???

Am I on the right track? Is there anything I'm missing? Will Wordpress handle having the site on a server connected to the old domain/URL, but showing a new URL to visitors? Are there any pitfalls?

Or should I just tell my friend to contact the domain registrar/hosting service to set up a web hotel connected to the new domain and move the Wordpress installation and site files? Or maybe the web hotel can just change the URL address of their server to match the new domain?

I didn't try implementing any of this, as I was afraid of bringing the site down, or even worse not even being able to access the WP-admin site to change it back in case of emergency. I know just enough to understand I don't fully understand how all of this works, which the way the question is posed probably reveals.

PS. I did try telling my friend they should have a WP developer do it, but apparently the person they have been using is not available, and they don't know who to ask on a short notice. I read other questions on similar subjects here, but I didn't find the answer to this specific case, unless there's something I'm not getting


Solution

  • The process of this is pretty straight forward. but depends if you know what web server is running and can handle editing the config file. or if your hosting have some sort of settings to add multiple domain targeting to specific directory/install

    The General process regardless of what server you have would involves 4 steps.

    1. Point the NEW domain to the server, this involves creating an A record on DNS manager pointing to that the server IP or directly changing the nameservers to that of your server if your server also has its own DNS manager like cpanel.

    2. Once the domain is pointed on the server, It should show the web server default page when you open the actual domain (if it has default http request page). and this is the step where you need to configure the domain on what to serve for HTTP request. This involves editing the web server config of your old domain and adding additional domain, this has different type setup and config based on your web server if its NGINX or Apache, like if its nginx the config normally is under /etc/nignx/conf.d/ and if apache the config /etc/apache2/httpd. This may a bit hard for you to do and you have to check some guide on how to do it based on your web server, and you may also have to issue an SSL (LetsEncrypt) on this new domain, but if your host has some settings that allows you to have multiple domains pointed to same install/directory then this could be an easy steps.

    3. This is where wordpress is involve, you have to first make sure the domain is now pointed on wordpress install, and when you open the domain in the browser, it should show the wordpress site. then you have to update the wordpress URL under Settings -> General. and additional steps you can use a plugin like Velvet Blues Update URLs to update all the old domain found in your database to a new domain. before doing this, its always advisable to create a back-up of the database first, so whatever happens you can easily put the original database back

    4. Old domain redirect, this depens on your web server and can be done inside your web server config you edited, or if using apache, can be directly done in .htaccess or if you even use Cloudflare as DNS Manager, Cloudflare can handle domain redirect to another domain via page rules.

    The most crucial part is step #2 and step #3, before doing step #3, make sure the domain is already configured to point on the wordpress directory. if you do step #3 and step #2 is not properly done, the site will be down.