Problem
You have a WordPress website but the domain eventually changes for some reason.
You change the domain name in the general settings page but for some reason, you find tha tnot all your iamges are appearing.
You look in the source and easily notice that there are a lot of specific links to your old domain name. Primarily from Dibi.
This isn’t all that easy to fix. For some reason, Divi installs files with the FQDN of your website.
Also, you may have a lot of posts with the old domain name.
So here’s how you can fix all that:
Solution
You will need file system level access and database acccess on the command line to achieve this in the most efficient way. If you don’t have this, perhaps ask your hosting company. I’m sure they would love the extra work…
Alright. I assume you are logged into the MySQL server using the MySQL command line. I’m also assuing you have moved into the correct database using the “use” command.
Must I say it? Back everything up.
Okay. use these commands to replace the domain name in the options, posts and postmeta tables:
update wp_options set option_value = replace(option_value, ‘oldDomain.com’, ‘newDomain.com’);
update wp_posts set post_content = replace(post_content, ‘oldDomain.com’, ‘newDomain.com’);
update wp_postmeta set meta_value = replace(meta_value, ‘oldDomain.com’, ‘newDomain.com’);
Okay. You’re done with the database. Exit out of that back to the command line.
Now update hte files in your website directory as follows: Again, you will need to update the path to your website here.
find /var/www/oldDomain.com/web ( -type d -name .git -prune ) -o -type f -print0 | xargs -0 sed -i ‘s/www.oldDomain.com/www.newDomain.com/g’
0 Comments