Your WordPress address and site address are very important as they reference both the address of your site on the web and the location of your site’s files. There are many reasons why you might need or want to change your WordPress URL. Perhaps you are changing domains, moving to a subdomain, updating from www to non-www, moving files around, or even migrating from HTTP to HTTPS. Whatever the case may be, there are a few different options you have when it comes to changing the URL, some more advanced than others.
How to Change Your WordPress URL
Follow the different methods below to change your WordPress URL, also known as the WordPress Address (URL) and or Site Address (URL). Be careful when editing these values, as you could bring your entire site down if they are entered incorrectly.
- Change WordPress URL in Admin Dashboard
- Change WordPress URL in wp-config.php File
- Change WordPress URL Directly in Database
- Change WordPress URL With WP-CLI
You can also see examples of additional scenarios in the WordPress Codex.
The first and most common method is to change your WordPress URL directly from within the admin dashboard. On the left-hand side, under “Settings,” click into “General.” You can then update the following:
- WordPress Address (URL): The address to reach your blog.
- Site Address (URL): The address of your WordPress core files.
Both should match unless you are giving WordPress it’s own directory. Remember that after you click “Save Changes,” your WordPress dashboard is now only accessible via the new URL.
If you are doing a fresh install at Kinsta, you will be given a temporary URL, such as sitename.kinsta.com. You can use the directions above to update the address.
You might also need to clear your WordPress site cache after updating the URLs, otherwise, you might receive a redirect error. If you’re a Kinsta client, you can clear your cache from the MyKinsta dashboard under the “Tools” section.
Note: If the fields above are grayed out, it is most likely because you already have hard-coded values in your wp-config.php file. In which case, proceed to method two below.
The second most common way to change your WordPress URL is via your wp-config.php file. It is important to note that values in wp-config.php override the settings in method one. If the fields are not editable (as seen below), it is most likely because they are hard-coded in this file.
The wp-config.php file is typically located at the root of your WordPress site and can be accessed via FTP, SSH, or WP-CLI. To hard-code WP_HOME and WP_SITEURL, simply input the following code towards the top of the file, changing the values to reflect your domain.
Below is an example of what your wp-config.php file might look like afterward.
You can always remove the two lines if you prefer to edit these values from the WordPress dashboard.
A third method you can use to change your WordPress URL is directly in the database using phpMyAdmin (which is accessible from your MyKinsta dashboard). This is usually done as a last resort.
In phpMyAdmin, click on your database on the left-hand side. Then scroll down and click on the “wp_options” table. If your database has a different prefix it might be named slightly different, such as wp56_options.
You can then edit both the values for the “siteurl” and “home” rows.
Enter your domain (URL) and click “Go.” Remember that after update this, your WordPress dashboard is now only accessible via the new URL.
And finally, the last recommend method for changing your WordPress URL is directly with WP-CLI. This is for you WordPress developers out there. For our customers, we provide SSH access so you can use WP-CLI. If you are unfamiliar with WP-CLI you can check out our in-depth post on managing WordPress from the terminal.
Here is an example of the command to update your WordPress URL values:
wp option update home 'http://example.com' wp option update siteurl 'http://example.com'
You can read more about the parameters available to you in the WP-CLI handbook.
Recommended tutorial for further reading: In-Depth Look at WordPress Permalinks and URL Rewriting