Question

Move wordpress from subdomain to root

Posted February 21, 2021 76 views
WordPress

Recently, I set up a one-click wordpress site hosted on a digital ocean droplet as a test environment while contemplating transitioning over from a ghost domain. In doing this, I set it up at “test.mydomain.com” which re-directs to my digital-ocean droplet. Navigating the droplet, it looks like the web server files and installation are all in the root www directory.

I would like to now transition this from “test.mydomain.com” to “www.mydomain.com”. I was able to change all of the database links to the proper (new) web address, and redirected the DNS records to the correct web address as well. The site loads, but strangely, the block editor cannot update posts, and some of the plugins fail to work correctly....

I have seen several posts on how to move wordpress from root to subdomain, but none of them seem to address this specific problem. I would appreciate any guidance.

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.

×
2 answers

Hello @robertcina

From your explanation, it appears you have already updated the URL’s in the database but it appears some of the links related to plugins are not updated in the database so it’s broken.

I would recommend you to install a plugin such as Better Search Replace to replace all the URL’s from https://test.mydomain.com/ to https://my.mydomain.com/ in your database.

Alternatively, you can re-install the plugins in which you are seeing the issue.

Also, there are some online guides such as below which you can help in this case:

https://www.wpbeginner.com/wp-tutorials/how-to-properly-move-wordpress-from-subdomain-to-root-domain/

Best,

Dikshith

Hello, @robertoagudeloc

If you’re already updated the Home and Site URLs from the WordPress admin panel then you can take the next step and update all the references for the IP address in your database as well.

Note:Please before you proceed take a snapshot of the droplet and also create a backup of the site (both files and database). This will ensure that if something goes wrong you can easily restore your site or droplet if needed

There are few ways to update the references in your database and it’s totally up to you which one you’ll choose. You can either change them manually if they’re not many or use an automation tool like a plugin or an external app.

One of the external apps that I’ve used and I know for sure that it’s working okay is: https://interconnectit.com/products/search-and-replace-for-wordpress-

You need to upload the script in your public_html folder and access it in your browser, then you’ll need to fill in your database details and enter the old name (IP address) and the domain name you want to use. Then you can first use the dry-run option and if there are references that need to be updated you can then run the script and update them.

Also, an alternative way is to use a plugin called “Duplicator” it will update all of the paths and references from the dev domain to the main domain. This is why we usually recommend using a plugin called: Duplicator. The plugin will generate a backup for your website’s files and database. Then when you import the files to the new domain, all of the references for the old domain name will be updated properly with the correct ones.

Another option is to use the All-in-One WP Migration plugin. The plugin will do the replacement for you during import. You do not need to use any additional database search and replace

https://wordpress.org/plugins/all-in-one-wp-migration/

Once this is done you can check the site for any errors as there might be some hardcoded references for the IP address in the files like paths to directories, files and etc.

Hope this helps!
Regards,
Alex

Submit an Answer