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

0
How to properly 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 arrived at the right place, because we are going to explain it step by step.

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

Transferring WordPress from a subdomain to a root domain

A subdomain is an extension of your root domain name. For example, http: // pic.scalsys.com is a subdomain of misitioraiz.com , where the last one is called the root domain.

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

Unlike moving a WordPress site to a new host or new domain name, moving a site to the root domain is a bit easier, mainly because both are 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 involve.

Are you ready? Let’s start!

Step 1. Create a full backup of the site

To achieve this, many add-ons are available to make automatic WordPress backups that can be used to safeguard your WordPress. One of them is WP Time Capsule .

However, even if you already have an automatic add-on installed to make backup copies, you DO NOT HAVE to skip this step. So the first step is to create a full backup of your site (including a backup of the database, and a backup of all your WordPress files and folders). To create the database backup, direct the tool options as indicated in the lower screenshot.

Once you have created a full backup, be sure to store it at a remote location, inside 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 or mysite ) and download all your WordPress files to your computer.

For this capture we are using the free FTP client Filezilla , but in all we will notice that, on the left, there are the local files, and on the right we will see the remote files.

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

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

Step 3. Change the WordPress URL and the URL configuration of the site

Once we have moved the WordPress files, we will not be able to access the WordPress administration area in the new root domain. Trying to log in to the root website will send us back to the administration area of ​​the subdomain website.

To solve this, let’s use the FTP client again and enter the root directory of our domain. Next, we must edit the wp-config.php file to add the following lines just before the line ‘That’s it, stop editing! Happy blogging ‘.

one
two
define('WP_HOME','http://ejemplo.com');
define('WP_SITEURL','http://ejemplo.com');

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

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

Now you can enter the administration area of ​​your WordPress site in the name of the root domain.

Step 4. Update the URLs

Your WordPress site has been moved to the root domain, but there may be links within the WordPress database that point to the subdomain.

Let’s solve this. You must install and activate the Velvet Blues Update URLs add-on .

After activation, you must visit the Tools section »Update URL.

In this section, you must enter the URL of your subdomain in the old URL field (old URL) and then add your root domain as the new one (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 search and update all the URLs in your WordPress database (it can take between a few seconds to whole 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 have moved the WordPress files, make sure that the traffic of your subdomain is correctly redirected to the root domain name.

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

The FTP client configuration has an option to always show the hidden files. In FileZilla, you are in the option Server> Force to show hidden files .

 

If you are using the cPanel File Manager, click the Settings button in the upper right corner of the screen. This will open the pop-up preferences. You must select ‘Show hidden files” and then click on the Save button.

 

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

one
two
3
4
5
6
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^pic\.scalsys\.com$ [NC]
RewriteRule ^(.*)$ "http://scalsys.com/$1" [R=301,L]
</IfModule>

Do not forget to replace your subdomain with your real subdomain, and example.com with your domain name.

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

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

Save the changes and upload your .htaccess file 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 put your website to the test to make sure everything works well, browsing and checking its functionality.

Successes!

LEAVE A REPLY