How to change your WordPress URL

Jordan Graves
Published: 6 September 2022Last updated: 26 October 2023
Share:

Rebrands and name changes take place from time to time, so you might need to update the WordPress URL that your site uses. Or, you may have finally finished creating your site on a development domain or subdomain and be ready to bring your site live, but you’re unsure how to go about doing so.

Due to the nature of WordPress databases, updating every single internal reference from your old domain to your new one can be time-consuming and difficult. WordPress sites use the URL of the main site for a lot of different internal processes, so it’s important to know how to update this properly to minimise disruption.

Note: Before attempting an update of your WordPress site’s URL, take a backup of the database to ensure you have a restore point. Our Timeline Backups service - which is included free with all WordPress Hosting - can be used for this.

Updating the WordPress URL within the Control Panel

Our WordPress Hosting platform includes inbuilt tools to update the site’s core settings in the form of the Settings area. To access this:

  • Log into My20i and head to your Manage Hosting area
  • Select Options > Manage on the hosting package you’d wish to edit
  • Under the WordPress Tools section of your package and select the Settings button

WordPress Settings in My20i, where you can update your domain.

Here, you’ll see areas where you can set the Site URL and Home of your WordPress site. Update these fields to the new URL, and hit Save Settings.

WordPress settings: change the URL

Change the WordPress URL in the WordPress Dashboard 

In order to change the WordPress URL from within the dashboard, head to the site’s wp-admin area and edit these details in Settings > General:

image.png

Then hit Save Changes.

Note: Changing the site’s URL while logged into wp-admin will require you to log back in again on the new site URL.

Change the WordPress URL in the Database

Note: If you’re unfamiliar with phpMyAdmin, take a backup of your site’s database before following the steps below so that you have a restore point available, just in case.

  • Log into My20i and head to your Manage Hosting area.
  • Select Options > Manage on the hosting package you’d wish to edit.
  • Head to the Web Tools section and select phpMyAdminimage.png
     
  • Select Sign In on your MySQL database. If you’re unsure which database is for your site, check your wp-config.php file.
  • You’ll be signed into phpMyAdmin. Select your database on the left, then the _options table from the list

image.png

  • You'll see entries for ‘siteurl’ and ‘home’. Edit the values of these entries and your site’s URL will be updated.

Change the WordPress URL in the wp-config.php 

For this step, navigate to your File Manager or FTP client and locate the wp-config.php file within your WordPress installation directory. For WordPress hosting packages, the file location will be public_html/wp-config.php.

image.png
The following definitions can be added within the wp-config.php file, with your URL set.

define( 'WP_HOME', 'http://20i-example.com' );  

define( 'WP_SITEURL', 'http://20i-example.com' ); 

Change the WordPress URL with WP-CLI 

For this fourth step, you will require SSH access to utilise WP-CLI (this is available to all 20i customers). Once you have connected to the hosting package via SSH, change directory to your WordPress installation – this is public_html for WordPress hosting packages. You will then need to run the following two commandsL

wp option update home 'http://20i-example.com'
wp option update siteurl 'http://20i-example.com'

Search and Replace with a plugin

Occasionally there may be other instances of the old URL being set within the database after a URL chance. Editing the database of your site manually can be risky if you’re unfamiliar with the process.

Alternatively, you can use a third-party plugin to do it for you.

We recommend Better Search Replace. This plugin provides an easy to understand UI in your wp-admin area where you can search for certain entries in your site’s database and update them. This includes searching for your current site URL and updating it.

To do this:

  • Log into your wp-admin area of your site, and search for the Better Search Replace plugin in your site’s Plugins > Add New area
  • Select Install and Activate
  • Better Search Replace will now appear as an option under Tools. Select it from the dropdown menu, and you’ll be presented with a form like below:

Better Search Replace UI

  • Enter your current URL in Search for and the URL you’re updating to in Replace with. You’ll see further down a selection of checkboxes:

Better Search Replace additional settings

  • Use Run as dry run if you want to see what tables the search and replace will update without actually changing anything, and hit Run Search/Replace
  • Once you’re happy with what changes will be made, uncheck the Run as dry run option and run the search and replace again

This will update all of your site’s URLs in the database for you.

Updating your site’s URL on WordPress can be handled with multiple different tools and approaches depending on where and how your site is hosted. Always make sure to take backups before making any major changes like this, to ensure that you have a restore point.

FAQs

Do I need to add a redirect to allow my WordPress site to load the new URL?

WordPress should automatically redirect any attempts to connect to your old URL to the new domain you’ve added, so a redirect shouldn’t be required.

I finished updating all of my site’s URLs but the old site still shows, what’s going on?

It’s likely due to one of three reasons. Either the old URL still exists inside the domain in some form, a redirect exists on the domain that is correcting to the old URL or the old URL is caching.

Check your database and .htaccess for any references to the old URL, and run a full purge of the Edge Cache.