Let’s say you have a website at https://mydomain.com/wordpress and want to change it to https://mydomain.com

Moving WordPress websites in particular can be tricky because the website url is embedded in the database files.   This article is based on the instructions on the WordPress Codex at  https://codex.wordpress.org/Moving_WordPress and works well if followed exactly on The Net Now servers.  If you are doing something a different like moving a site from one server to another, the instructions would be a little different.  Ask us or refer to the WordPress Codex link above.

Let’s take you through the following steps:

  1. Backing up your new WordPress site
  2. Archiving the old site / getting main directory ready for new files
  3. Changing URL in WordPress
  4. Moving website files
  5. Updating the paths on the new database

1. Backing up

There are two parts to the WordPress sites.  The site files and the database.  At this time I am talking only about backing up your new WordPress site that you have in the subfolder, however, you may also want to use some of these methods to backup your old site as well.

Database Backup

You will need to make a backup of your database.  There are 3 easy options.

Option 1:
You can login to Cpanel and backup your database via the BACKUP icon.

Option 2:
If you created the WordPress site with Softaculous, you can go to Cpanel, Softaculous Apps Installer, WordPress and go to the backup icon for your current installation.  There you can select whether you are backing up the files, or database or both.   If you do both, you won’t need to worry about backing up the files later.

Option 3:
We usually make a backup of the database using phpMyAdmin. Click the phpMyAdmin icon inside your Cpanel. Select your database, go to Export and click ‘Go’ to export using the Quick Export Method. More info here.

WordPress Site Backup

Next you need to backup all of your wordpress files.  There are a few methods to do this.   Pick ONE of the four methods below.

Option 1:
The first method  would be to go to the Backup area in Cpanel and download a copy of your Home Directory.  This is just above where you may have downloaded the database if you didn’t use phpMyAdmin.   This allows you to download the entire Home directory which includes far more than just your WordPress files so it may be quite a large file.  It will also copy all the settings, email, and your old and new websites.

Option 2:
You could also use and FTP program like FileZilla to download all the files in your new website.   If you created it in a subdirectory called newsite when you created wordpress, then you would need to navigate to the home/public_html/newsite directory and download the contents to your computer.   Of course, if you are also backing up your old site located in the public_html, and you want to have both sites backed up, then download everything inside the public_html folder.

Option 3:
If you created the WordPress site with Softaculous, you can go to Cpanel, Softaculous Apps Installer, WordPress and go to the backup icon for your current installation.  There you can select whether you are backing up the files, or database or both.

Option 4:
The last method I’ll mention here makes it very simple to recover the site quickly if you find somethings gone wrong.  WARNING:  Make SURE you have enough disk space for making backups!
Go to File Manager in Cpanel (in FILES section).

Click on +Folder in top left corner.   This allows you to add a new directory.  I usually add it to the root of the site in /home   You can name it something like backup

Then navigate to the folder (ie.  public_html/newwordpresssite) that you wish to copy over to the new backup directory you’ve created above.  On the right side, you will want to select all of the files you are copying over to your backup folder.  You can see there is a Select All link in the menu.  Once all your files are selected, they will be highlighted.   You can then use the Copy link to move them to the new backup directory as shown in screenshots below.  Note:   Use Copy instead of Move, so you will still have the original files in your subdirectory.  You do NOT want to Move the files when making the backup.   However, optionally, when you are moving the files in Step 4, you can use the Move command if you are feeling confident, or just use Copy and at a later time remove the unneeded files.

2. Archiving old site

Next you need to make sure your public_html folder is ready to receive your new website files.  Ideally, it’s empty except for the subdirectory containing your new site.  If you still have your live site there, you should archive the files if you will need them.   Ideally, this would be to download them to your computer instead of the server.   However, if you need to, you could create a directory called to store the files on the server following a similar method as backing up the files in using File Manager from Step 11.  You might want to make the directory that receives the old files have a name like ‘oldsite’ or ‘archived’.   It can be in the home directory or in the public_html directory.   Just be sure once you have copied or moved the files, your original subdirectory containing the new WordPress site is still in same location.

3. Changing site URL’s in WordPress

    At this point, you will login to your new wordpress site to update the sites URL’s.  Change both the WordPress Address (URL) and the Site Address (URL) under Settings -> General.
    You will be changing it from something like https://mydomain.com/wordpress to https://mydomain.com
  • Click on ‘Save Changes’.
  • Once you’ve made the changes below, you’ll be logged out and will then move to the next step of moving your files to the main directory.  Don’t worry, and don’t bother trying to view your site at the new url yet since there’s nothing there yet.

4. Moving website files

We’re nearly there!  Now you need to move all the files that were in the subfolder with the new WordPress site over to the main directory (public_html).

  • Using File Manager, navigate to your wordpress directory until you see all of your site files on right side.   Use the Select All Command and then the Copy command to put the files into the public_html folder.   Refer to procedures in Step 1.   You can use the ‘Up one level’ menu item to go from the subdirectory to the public_html directory where you should see all your wordpress files plus the original subdirectory.  It’s fine to leave it there for the time being, but you should remove it once everything is working properly.  You can rename it if you wish to avoid confusion and help you detect if any links on the site are trying to go to the subdirectory still.
  • Try going to your admin area using the new URL.  Example:  https://mydomain.com/wp-admin or https://mydomain.com/wp-login.php.
  • Go to Settings -> Permalinks.   Confirm the settings are correct and hit Save Changes button at bottom.  This updates the .htaccess file with the new URL.

5. Updating paths

Now, you might think you are done, however, there are probably going to be a number of instances of the URL still going to old subdirectory url.

  • Check your Menu items that are working as expected.
  • For other links that are in various places in database, we suggest you install a plugin in wordpress called “Better Search and Replace”. You will use it to do a replacement for all of your domain names. (For example, replace http://yourdomainname.com with https://yourdomainname.com.) Once installed, it’s found under the Tools menu.  Just enter the old and new url and we suggest doing a dry run https://en-ca.wordpress.org/plugins/better-search-replace/  You can’t simply go and edit the database manually with the correct URL due to possibility of data serialization errors.
  • If you use Softaculous, you should go to the settings and edit them to show your new directory and URL or it may report to you that there are problems when it can’t find your site.

Pin It on Pinterest