You probably remember setting up your WordPress URL when you installed WordPress. Or, if it’s been a while, you might not. But from time to time you may decide you need to change your Site URL. Because of the way WordPress uses the Site URL, it’s important to use the proper methods to change it, otherwise, you could break your site.
Why Would You Want or Need To Change the Site URL?
There’s a lot of reasons why you might want to or need to change your WordPress Site URL. Some of them include:
- You’ve decided to (wisely) use HTTPS.
- You’ve changed your domain name.
- You’re moving your WordPress installation from one directory to another.
- You’re moving your WordPress installation from one subdomain to another domain.
- You started designing your site using a local server, like WAMP, XAMPP, and have decided to transfer to your new web hosting, but with a different URL.
There are some other instances where you may need to update your Site URL as well, namely if you are seeing a lot of too many redirect error messages.
WordPress Address vs. Site URL
When you change your WordPress Site URL, you need to update 2 settings separately – WordPress Address and Site Address. This can be confusing if you don’t know the difference between the two settings.
Your WordPress Address is the address/location where WordPress and the files/folders it requires for operation are stored, as well as your administrative pages, media files, your plugins, and themes, etc…
Your Site Address is the publicly addressable part of your website – i.e. the URL visitors type in their browser to access your website.
Typically, these addresses are the same, however, some users may want to store their WordPress files in a separate directory and have their website as the Site URL.
We will cover the various methods to change your Site URL below.
How to Change Your WordPress Site URL
We will cover the various methods to change your Site URL below.
Using the WP-Admin Area
Step 1: Login to your /wp-admin and using the menu on the left hover over Settings and click General.
Step 2: Beneath General Settings you can enter a new WordPress Address URL and a new Site Address.
Using the two text boxes, you can enter your new URLs.
Don’t forget to click Save Changes at the bottom to store the settings. You’ll also want to visit your site to make sure the new URLs are working okay.
How to Change WordPress URL in wp-config.php File
The second most common way to change your WordPress URL is in your
wp-config.php file. It is important to know that values in wp-config.php will override the settings in your WordPress admin panel (General Settings)
In your wp-config.php file, add these two lines somewhere above the line that tells you to stop editing:
define( 'WP_HOME', 'https://mynewdomain.tld' ); define( 'WP_SITEURL', 'https://mynewdomain.tld' );
Save your wp-config.php file and close it.
How to Change WordPress URL With WP-CLI
WP-CLI is a set of command-line tools for managing WordPress installations, without using a web browser.
Step 1: Open up an SSH connection to your hosting account. If you are not familiar with how to do this, please review our KB on the topic here.
Step 2: Once you are connected via SSH, you would use the following commands:
wp option update home 'https://mynewdomain.tld' wp option update siteurl 'https://mynewdomain.tld'
After you type out each command, press enter/return on your keyboard to execute the change.
Congrats! Using this command you will have updated your WordPress Site URLs!
How to Change WordPress Site URLs using phpMyAdmin
Step 1: Log in to your cPanel. There’s a lot of ways to do this, but the sure-fire easiest way is to log in to your Client Area, then open your cPanel.
Step 2: Under the Databases section, click phpMyAdmin to open the utility.
Step3: When phpMyAdmin opens, look for your database on the left:
Click the + next to the database to expand it. Once expanded, click on the wpft_options table. Note, don’t click the + next to it, just click on the name.
Your table prefix may vary, however, your table names will still be the same, so you’ll want to click the one that ends in _options in your phpMyAdmin.
Step 4: After clicking on the options table, you will see a screen that displays each row in that table. It will look very similar to the one below:
The rows we need to look for are at the top. Look under the column option_name for the ‘siteurl’ and ‘home’:
Beneath the column option_value you can triple-click into the row to make the data in that column editable. After doing so, enter your new Site URL Address in BOTH the siteurl and home rows.
Congrats! Using this method you will have updated your WordPress Site URLs!
How to Change WordPress Site URLs using WordPress Search and Replace Plugin
The Better Search Replace is a fantastic (and free!) plugin you can use to update your website URLs. This plugin is especially useful if you have changed your domain name entirely as it will scan your WordPress site for any mention of your old domain in your posts and pages and update the links with your new domain name.
Step 1: Login to your /wp-admin and using the menu on the left, hover over Plugins and in the little menu that expands, click Add New.
Step 2: Using the search in the top right corner, search for Better Search Replace, then press enter/return on your keyboard to submit the search query.
Step 3: Locate the Better Search Replace plugin in the results and click the Install button to download & install the plugin.
After the plugin has downloaded, click the blue Activate button to enable the plugin.
After activating the plugin you will be redirected to the Plugins page where you will see the installed plugins listed.
Step 4: Open Better Search Replace by navigating to the menu on the left and hovering over Tools, then click Better Search Replace.
Step 5: On the Better Search Replace Screen, you have several options. Let’s review them:
In Search For you would enter your old domain name.
In Replace With you would enter your new domain.
In Select Tables you would highlight all of the WordPress database tables you want to search and update.
If your search is case-sensitive, you can check the case-sensitive box.
Replace GUIDs: It is generally advised to leave this unchecked. For more info, click here.
Lastly, you have the option to run as a dry run. This option will scan the database, but will not make any changes, allowing you to see what will change beforehand.
To update your site’s posts and pages to your new domain name, enter the old domain in Search For and the new domain in Replace With, then uncheck the run as dry run box and click the Run/Search Replace button to make the changes.
If you enjoyed this tutorial, then you’ll love our support! All ChemiCloud’s hosting plans include 24/7 support from our amazing support team. Check out our WordPress hosting plans and have your website migrated today!