wiki:how-to/wordpress/change-site-url

Version 3 (modified by JaimeV, 6 years ago) ( diff )

--

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 sitedomain.org/web

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

siteuser@server:~/sitedomain.org/web$ wp option get siteurl

http://sitedomain.org

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

siteuser@server:~/sitedomain.org/web$ wp option set siteurl https://sitedomain.org

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:~/sitedomain.org/web$  wp search-replace --dry-run http://sitedomain.org https://sitedomain.org --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:~/sitedomain.org/web$  wp search-replace  --dry-run  http://www.sitedomain.org https://sitedomain.org --skip-columns=guid
siteuser@server:~/sitedomain.org/web$  wp search-replace  --dry-run  http://oldsitedomain.org https://sitedomain.org --skip-columns=guid

Other methods

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

https://codex.wordpress.org/Changing_The_Site_URL

Note: See TracWiki for help on using the wiki.