wordpress domain change

info

2022-05-18

mi

Are you about to duplicate a wordpress site, changing a domain or such?

Please backup your files and your database first.

ssh recipe:

ssh username@domain
pw: verystrongpw
ls //list folder
cd //to my directory
tar -vcf mybackup.tar.gz . //do not forget the last dot here

After upload, open the folder in the new place like this:

tar -zxvf mybackup.tar.gz oder tar -xvf mybackup.tar.gz

Now it's time to take care of the database:

UPDATE wp_posts SET guid = replace(guid, 'https://alt.domain','https://new.domain');
UPDATE wp_posts SET post_content = replace(post_content, 'https://alt.domain', 'https://new.domain');
UPDATE wp_links SET link_url = replace(link_url, 'https://alt.domain', 'https://new.domain');
UPDATE wp_links SET link_image = replace(link_image, 'https://alt.domain', 'https://new.domain');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'https://alt.domain', 'https://new.domain');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'https://alt.domain', 'https://new.domain');
UPDATE wp_options SET option_value = replace(option_value, 'https://alt.domain', 'https://new.domain') WHERE option_name = 'home' OR option_name = 'siteurl' OR option_name = 'widget_text' OR option_name = 'dashboard_widget_options';
UPDATE wp_options SET option_value = replace(option_value, 'https://alt.domain', 'https://new.domain');

Last step - do not forget to edit your config.php


Have fun!