How to successfully move WordPress from a subdomain to a root domain

Do you want to move your WordPress site from a subdomain to a root domain? You have come to the right place, because we are going to explain it to you step by step.

The process is quite easy to follow, and we will also teach you how to preserve your SEO efforts, so you don't lose positions.

Transferring WordPress from a subdomain to a root domain

A subdomain is an extension of your root domain name. For example, http://mysubdomain.misitioraiz.com is a subdomain of misitioraiz.com, where the latter is the so-called root domain.

Search engines consider that the subdomain is a totally different website. This is why you should make sure correctly redirect search engines to the root domain after transfer. This will help you retain search rankings after you move your website.

Unlike moving a WordPress site to a new host or domain name, moving a site to the root domain is a bit easier, mainly because they are both hosted (commonly) within the same web hosting company. Thanks to having to move all the files within the same server, the process allows you to skip some steps that a real hosting move implies.

Are you ready? Let's get started!

Step 1. Create a full site backup

To achieve this there are many WordPress auto backup plugins available that can be used to back up your WordPress. One of them is WP Time Capsule.

However, even if you already have an automatic backup plugin installed, you MUST NOT SKIP this step. So the first step consists of create a full backup of your site (including a database backup, and a backup of all your WordPress files and folders). To create the database backup, go to the tool options as indicated in the screenshot below.

Once you've created a full backup, be sure to store it in a remote location, either on your computer or on an external drive.

Step 2. Moving your WordPress files from the subdomain to the root folder

To achieve this you must enter your website using an FTP client or using the cPanel File Manager. Once connected, go to the location of your subfolder (ex: public_html, www either my place) and download all your WordPress files to your computer.

Next, open the public_html folder of your domain. Depending on how your WordPress hosting environment is set up, this folder could also be named www or have your domain name.

Now you must upload all the WordPress files that you have previously downloaded to the root directory of your domain.

Step 3. Change WordPress URL and Site URL Settings

Once we've moved the WordPress files, we won't be able to access the WordPress admin area on the new root domain. Attempting to log in to the root website will send us back to the subdomain's website admin area.

To fix this, let's go back to using the FTP client and enter the root directory of our domain. Next, we need to edit the file wp-config.php to add the following lines just before the line 'That's it, stop editing! Happy blogging.

define( 'WP_HOME', 'http://example.com' );
define( 'WP_SITEURL', 'http://example.com' );

Do not forget replace example.com with your own domain name. If you want your root website to use www you will need to enter URLs with the www prefix. Also, if you have an SSL certificate, remember that instead of http: it should say https:

Save the changes and upload the file wp-config.php to your website.

You will now be able to enter the administration area of your WordPress site at the root domain name.

Step 4. Update URLs

Your WordPress site has been moved to the root domain, but there might be links within the WordPress database pointing to the subdomain.

Let's fix this. You will need to install and activate the plugin Velvet Blues Update URLs.

After activation, you need to visit Tools » Update URL section.

In this section, you need to enter your subdomain URL in the old URL field and then add your root domain as the new URL. Next, in the “Choose which URLs should be updated” area, you should check all the options except “Update ALL GUIDs” as shown in the image.

Once you have filled in the fields and checked the correct options, press the 'Update URLs NOW' button to start the process.

The plugin will fetch and update all URLs in your WordPress database (it can take anywhere from a few seconds to a few minutes, depending on the size of your database). Once finished, you will see a success message.

Step 5. Redirect all traffic from subdomains to the root domain

Now that you've moved the WordPress files, let's make sure that your subdomain's traffic is properly redirected to the root domain name.

Go to your subdomain folder with the FTP client and make sure hidden files are forced to be visible.

The FTP client settings have an option to always show hidden files. In FileZilla, it is found in the option Server > Force show hidden files.

If you are using the cPanel File Manager, click the Settings button in the top right corner of the screen. This will open the preferences popup. You need to select 'Show hidden files' and then click the Save button.

If your subdomains folder already has a file .htaccess, you can delete it and create a new one. Inside the new file .htaccess You must copy and paste the following code:


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursubdomain.example.com$ [NC]
RewriteRule ^(.*)$ "http://example.com/$1" [R=301,L]

Don't forget to replace your subdomain with your actual subdomain, and example.com with your domain name.

Note that the RewriteRule line uses a non-www URL. If you want to use www in your root domain, you will need to add your URL with the www prefix.

Also, remember what we said earlier regarding SSL certificates. If you have one, your address will be https instead of http.

Save changes and upload your file .htaccess to the server.

And that's it! You have successfully moved your site from a subdomain to a root domain. Now you can visit your website to see it in action.

And remember: always test your website to make sure everything works fine by browsing it and checking its features.

successes!

We are Duplika

Give your site the hosting it deserves

no comments on How to successfully move WordPress from a subdomain to a root domain

back to blog

Duplika

Duplika

We are online, we are not a bot :)

I will be back soon

Duplika
Hi 👋
Select the prefered contact method to get in touch.
Connect via:
chat