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.
You can also see examples of additional scenarios in the WordPress Codex.
1. Change WordPress URL in Admin Dashboard
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.
You might also need to clear your WordPress site cache after updating the URLs, otherwise, you might receive a redirect error.
2. Change WordPress URL in wp-config.php File
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.
3. Change WordPress URL Directly in Database
A third method you can use to change your WordPress URL is directly in the WordPress 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.
4. Change WordPress URL With WP-CLI
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.
If you liked this article and want to increase your WordPress site’s speed. Read this article too.