WordPress: Bulk URL change from SQL


Let's "talk" about WordPress. After merging the iguru.gr database into the iguru database, all the links to the images showed the iguru.gr directories. For example:

wordpress-code

https://static.iguru.gr/files/2016/10/Mechanic.jpg

So even though there were posts in iguru the images kept coming from iguru. So after transferring all the files from iguru / uploads to the iguru dir of the same name, we had to change the URLs en masse to get the images from:

https://static.iguru.gr/files/

Let's see how it's easy to do (make a backup of your database before trying it):

Below are the SQL commands we used to change URLs across the database.

UPDATE wp_options SET option_value = replace (option_value, 'https://static.iguru.gr/files', 'https://static.iguru.gr/files') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace (guid, 'https://static.iguru.gr/files','https://static.iguru.gr/files');
UPDATE wp_posts SET post_content = replace (post_content, 'https://static.iguru.gr/files', 'https://static.iguru.gr/files');
UPDATE wp_postmeta SET meta_value = replace (meta_value, 'https: //static.iguru.gr/files','https: //static.iguru.gr/files');

Registration in iGuRu.gr via Email

Enter your email to subscribe to the email notification service for new posts.


Read them Technology News from all over the world, with the validity of iGuRu.gr

Follow us on Google News iGuRu.gr at Google news