For most businesses, re-branding means changing domain names. In some cases, the business name won’t change but the domain will need to. An example of the latter might be if your domain name example.net is changing to example.com. The company name remains the same but the domain name changes. You might even change from HTTP to HTTPS, which in Google’s eyes, is a new site.
I'll presume you’ve already found the perfect domain name and you’re ready to change your WordPress website, so let’s get into it.
The big question is, how do we change the domain name URL without affecting our ranking and traffic?
Copy The Old Website To The New Website Location
The first thing to do is to create the new site, get it running nice and fast, and make sure there are no broken links, spelling errors, or missing ALT tags.
The beauty of WordPress is that the entire website files (apart from the database) can be moved from one location to another or copied.
There are several ways to make this change but the following method is the safest. If your website is already receiving traffic, you won’t want to lose those visitors.
Step 1: Create the AddOn Domain
In your web hosting cPanel, create an “Addon domain”. This is the new domain name you’ve chosen for your website.
Every cPanel is different but they share similarities in how they name the important features. Look for additional domains, AddOn or Add-On Domains.
Click the Addon button and type the name of your new domain.
Return to the cPanel main area and open File Manager. Check that the domain folder has been created. Check under the public_html folder or the Web folder. Once you verify that the folder exists, move on to the next step
Step 2: Copy the WordPress files
Copy the files from the original domain name folder to the new folder. (FastComet has one of the easiest to use cPanel’s and administration area. If you get into trouble, their support is excellent and quick to respond)
Open the original folder and select all the files and folders. A quick way to do this is to click the Select All button near the top of File Manager.
Click Copy or type Command and C (CTRL + C on Windows). That will copy all files.
A box will pop up asking where you would like to copy the files. Change the file path to the new folder you created in step 1.
Step 3: Create the new SQL database
This might sound hard but it’s pretty easy to do. We first need to make an empty database.
In Cpanel, look for the Databases section. We’ll use the MYSQL Databases section first.
- Click MYSQL Databases.
- Under Create New Database, type a short name for the new domain.
- Next, create a new MySQL username. These names are arbitrary but I like to keep them fairly consistent to make identifying them easier. Make (and write down or record) a new password and click Create User.
- Next, add this user to the database.
- Under Add User to Database, select the username you created in the last step. Select the new database and click Add.
That’s it. The new database is ready with it's own administrative user.
Step 4: Copy the old database into the new database
Now we need to copy the contents of the original website database into the new (empty) database for the brand new domain.
Return to Cpanel and look for phpMyAdmin. Click to open.
PhpMyAdmin is a simple tool that lets you manipulate SQL databases, where the actual data (posts, comments, etc) of your website are stored.
Find the original database.
If you’re not sure what the name of the database is, you can find it by looking inside the wpconfig.php file. In a separate tab, open File Manager and navigate to the original website folder. Scroll down until you find wp-config.php. This is a very important WordPress file.
Right-click the file and select View.
The file will open in read-only mode (so you can’t accidentally change it).
Look for the line /** The name of the database for WordPress */
The following line reveals the name of the database. It will look something like this.
Note this part cpanelname_wp391
Head back to phpMyAdmin and look for this database name in the list of databases on the left-hand side. Click to open.
Select Export from the top bar. Leave the Export Method as Quick and click the Go button.
A download window will open. Save the .sql file somewhere on your computer.
Next, click the name of the brand new database on the left-hand side.
We will now import the information into the empty database. Click Import from the menu bar at the top. Select the .sql file you just downloaded and let phpMyAdmin import the database.
Step 5: Edit the domain name in mySQL
Expand the database folder structure and look for the entry that includes _options in the title. Click this entry.
The right-hand panel will now show something like this.
You need to edit the first two entries.
Click each entry to edit and change the domain name.
Step 6: Edit the domain name in wp-config.php
Head back to File Manager but this time open the folder for the new domain.
Find the wp-config.php file and this time edit the file rather than just view it.
You will need to edit three lines in this file.
define('DB_NAME', ‘original_db_name’); define('DB_USER', 'original_db_user’); define('DB_PASSWORD', 'original_user_password’);
Where it shows your original database name (shown as original_db_name in the example above), change to the new database name. Do the same for the username and password.
Save the file.
At this point the new site should be ready to view.
Check the Website On The New Domain
If you’ve set up the name servers with your domain registrar to point to the web hosting, then the domain name should resolve. Open a web browser tab and enter the domain name. Make sure it's working ok.
The final step can be a tedious one but fortunately, there are ways to speed it up. The new site will still contain links to images and pages in your old website. There are two ways to fix this.
- Open up every blog post and page on the site and edit the URLs manually. If it’s a small website, this is the best option.
- Use a WordPress plugin like Search & Replace to change every incidence of the old URL with the new URL.
Create URL Mapping
Once the new website is ready and you’ve checked that all links and problems are ironed out, you need to let Google know about the domain name change.
There are two main steps in this process
- Create a redirect map for all the old URLs to the new URLs.
- Use Google’s Change of Address tool in Google Search Console to make sure your new domain doesn’t lose and SEO juice.
Open Excel and copy this list to an excel column.
Add a column with the text “Redirect 301” before this column.
In a new worksheet, copy the list and replace the old domain name with the new domain name. Use Excel’s Replace All option.
Copy this new list to the first sheet in the third column.
It should look something like this:
Now you’ve got a 301 redirect mapping ready to implement.
Navigate to the original domain name’s folder in Cpanel and find the .htaccess file. Open the file for editing.
Paste the excel cells at the start of this file and save the file.
Test out the redirections. Open a web browser and go to any page on your original site. You should be redirected to the new site automatically. If not, there’s something wrong with the mapping.
Inform Google Of The Change Of Address
The final task is to let Google know about the website change.
But first we need to add the new site to Google Search Console (GSC)
- Open GSC and click Add A Property.
- Fill out the details for the new website as you would with any new GSC property. Verify the property.
- Next, open the property for the original website and click the cogwheel near the top right of the GSC interface. Select “change of address”.
- Pick the new domain from the list.
- Check the 301 redirects are working.
- Check the verification methods on the original site are still working.
- Click Submit to start the change of address process.
Congratulations, you’ve changed your domain name and moved the website. You now have the new website working with a new domain name and a full backup of the original site in case of problems.
Keith is the founder of Fat Frog Media. He has worked in the tech, fitness, food, and hospitality industries. Keith helps businesses improve their marketing and conversion rates.