If you have made a website using a webhosting package, but you are not happy about having the website live via yourdomainname.com, you can move your website to a subdomain such as subdomain.yourdomainname.com. Or perhaps your website was made on a subdomain, and now you want to move it to your root domain.
In this tutorial we will explain how to move your website from one place to another on your webhosting package.
This tutorial shows how to move your website to a different location within your webhosting package. In this case, you can leave the database as is.
If you want to make an exact copy of your website so you can have the website in two places at once, you will need a copy of your database and website files. This can be useful if you want to change your website drastically, but you want to leave the original version of your website unchanged on your root domain.
Changing your WordPress URLs
If you are moving a WordPress website, make sure you change your website URLs to the new (sub)domain first. If you don't, you will not be able to log in to your WordPress dashboard after moving your files. You can change your URLs by following these steps:
Changing the URLs via your WordPress dashboard
Before moving your website, log in to your website's WordPress dashboard. Go to 'Settings' in the menu on the left side of the screen. You will find your WordPress Address (URL) and Site Address (URL) here.
Change these both to the new URL of the (sub)domain to which you plan to move your website. Save the changes at the bottom of the page. This way, you prevent being redirected to the original (sub)domain after moving your files and therefore not being able to log in to your dashboard.
Changing the URLs via your database
If you have not changed the website URLs before moving your files, you will have to change them afterwards via your database.
In your database you will find these URLs in the 'wp_options' table. Edit the values next to 'siteurl' and 'home' to the URLs of the new (sub)domain. You can do so by clicking on the field below 'option_value' (highlited in red in the image below) or by clicking 'Edit' at the start of the row.
Check the DNS settings of your domain
If you want to move your website to a subdomain, first make sure you have created the subdomain on your webhosting package. It is also important that the DNS settings are set correctly.
If your domain uses the DNS settings of your webhosting package, your website will be visible almost immediately after moving it. You can read all about the DNS of your webhosting in the article 'The DNS settings of my Web Hosting'.
Have you changed your domains DNS before, make sure to add a DNS record. In the article 'Entering DNS records and nameservers via the control panel' you will find how to enter DNS records.
- For a subdomain: Enter only the subdomain as the name, use the 'A' type record and enter the IP-address of your webhosting as the value.
- For the root domain: Enter '@' as the name, use the 'A' type record, and enter the IP-address of your webhosting as the value.
Your SFTP information
Before following the steps in this tutorial, look up your SFTP information and use this to log in to an SFTP client such as FileZilla or Cyberduck. In the examples we use FileZilla.
You need the following information to log in to an SFTP program:
- Username
- Host
- Password
- SFTP port: 22 or 2222
The password for SFTP is sent to you by email shortly after ordering your web hosting package. If you cannot find the password or simply want to use another password, you can change the password by following the steps on this page.
Moving your website from the root domain to a subdomain
Step 1
Make sure the folder to which you are moving the website is empty. Your webhosting package automatically creates an index.php file when making your subdomain or www folder. This file directs you to the TransIP 'reserved' page.
In this example we are moving the website to the subdomain 'blog'. Open the subdomain you are moving the website towards first, via your SFTP client. The subdomain you created is usually in the folder 'subsites' on the right below 'Remote site'. Click on the index.php file with your right mouse button and delete it by clicking 'Delete'.
Step 2
Open the 'www' folder, which contains your website's files if your website is on your root domain, and select all files present in the folder. Next, drag them to the subdomain folder where you want your website to be.
After following the steps above, your website is moved to the subdomain and can be visited via the new URL; subdomain.yourdomainname.com. If you want to move the website back to the root domain, simply drag the files back to the 'www' folder.
Moving your website from a subdomain to the root domain
Step 1
To move your website to your root domain, make sure the 'www' folder is empty first.
Open the 'www' folder via your SFTP client. You will find the folder on the right screen below 'Remote site'. Select all files in the 'www' folder. Remove them by right clicking the selected files and clicking 'Delete'.
Step 2
Open the subdomain folder in which you find your website's files. You will usually find the subdomain in the 'subsites' folder on the right screen. Select all files in the folder of your subdomain and drag them to the now empty 'www' folder.
After following the steps above, your website is moved and can be visited via your root domain; yourdomainname.com. If you want to move your website back to your subdomain, simply drag the files back to the original subdomain folder.
Moving your website from a subdomain to a different subdomain
Step 1
In this example we are moving the website from the subdomain 'test' to the subdomain 'blog'. Open the subdomain you are moving the website towards first, via your SFTP client. The subdomains are usually in the folder 'subsites' on the right below 'Remote site'. Select all files in the folder (usually, there should be at least an index.php file) and remove them by right clicking the selected files and clicking 'Delete'.
Step 2
Open the folder that contains your website's files. This is the 'test' folder in our example, meaning our website is currently on test.transiptutorials.com. Select all files in that folder. Next, drag them to the folder of the subdomain where you want your website to be.
After following the steps above, your website is moved and can be visited via your new subdomain. In our example this is; blog.yourdomainname.com. If you want to move your website back to your original subdomain, simply drag the files back to the other subdomain folder.
In this tutorial we have showed you how to move your website to a different location within your webhosting package.