Changing the wordpress site url

Using the wp admin interface

If you still have access to the wordpress admin interface for your site under the "Settings->General" screen changing the values of the two fields named "WordPress Address (URL)" and "Site Address (URL)" is the easiest way to do this.

Using the wp-cli utility

However if you do not have access to the admin interface or want to be sure that this value is changed everywhere in your site we recommend using the wp-cli utility which we've installed on all of our standard servers for you. You will need to access the command line via ssh to use this tool.

Once you have access to the server you can navigate using the change directory command cd to your web folder or the folder that contains your wordpress installation before invoking the wp-cli utility with the command wp.

siteuser@server:~$ cd

wp-cli can both check and directly set the siteurl configuration value from the command line.

siteuser@server:~/$ wp option get siteurl

In this example we will replace http with https for the site.

siteuser@server:~/$ wp option set siteurl

The wp-cli utility can also search and replace any instances of a string in your database to replace text embedded in posts and other configuration fields in your site that might still be pointing to the old url.

This example uses the --dry-run argument to test without making any real changes. Remove the --dry-run argument and run again to make those changes effective.

siteuser@server:~/$  wp search-replace --dry-run --skip-columns=guid

You may also choose to use the same method to ensure other versions of the url that might exist in your site. Below are just a couple of examples

siteuser@server:~/$  wp search-replace  --dry-run --skip-columns=guid
siteuser@server:~/$  wp search-replace  --dry-run --skip-columns=guid

Other methods

The official wordpress documentation also recommends several other valid methods of changing your site url.

Last modified 3 years ago Last modified on May 22, 2018, 1:06:07 PM