This article describes how to change the site address only within WordPress itself. To rename a site on a hosting (virtual host in the section "My sites»And the site directory on FTP), use instruction.
https://
... In the event of a protocol mismatch on the site, a cyclic redirect between protocols may occur http://
and https://
.www
or without www
must match the new address. For example, if a redirect to an address from www is set in the site settings, then the new address must also be from www. In the event of a protocol mismatch on the site, a cyclic redirect may occur between the address with www
and without www
.To change the site address using database queries:
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old_domain.com', 'http://new_domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE(guid, 'http://old_domain.com','http://new_domain.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://old_domain.com', 'http://new_domain.com');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://old_domain.com','http://new_domain.com');
UPDATE wp_comments SET comment_content = REPLACE (comment_content, 'http://old_domain.com', 'http://new_domain.com'); UPDATE wp_comments SET comment_author_url = REPLACE (comment_author_url, 'http://old_domain.com', 'http://new_domain.com');
http://
or https://
and there should not be a slash at the end /
... An example of a valid address: http://example.com
.To change the site url using the WP-CLI utility:
cd ~/example.com/www
In the team instead of example.com/www
enter your details.
wp search-replace 'old-address.com' 'new-address.com'
In the team instead of old-address.com
specify the old site address instead of new-address.com
- new.
As a result of executing the command, information will be displayed about where and how many replacements were made.
You can customize search with replacement more subtly (for example, only for certain tables or columns) using additional attributes described in documentation.