Skip to content

Instantly share code, notes, and snippets.

@fearlex
Last active March 11, 2019 21:26
Show Gist options
  • Save fearlex/546c842cb3df428e3ee0394801941974 to your computer and use it in GitHub Desktop.
Save fearlex/546c842cb3df428e3ee0394801941974 to your computer and use it in GitHub Desktop.
Migrate http to https
##-- Images Double Quote
UPDATE `wp_posts` SET post_content = ( Replace (post_content, 'src="http://', 'src="//') )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
##-- Images Single Quote
UPDATE `wp_posts` SET post_content = ( Replace (post_content, "src='http://", "src='//") )
WHERE Instr(post_content, 'jpeg') > 0
OR Instr(post_content, 'jpg') > 0
OR Instr(post_content, 'gif') > 0
OR Instr(post_content, 'png') > 0;
##-- Update SRC USING www with double quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, 'src="http://www.yoursite.com', 'src="https://yoursite.com')
WHERE post_content LIKE '%src="http://www.yoursite.com%';
##-- Update SRC WITHOUT www with double quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, 'src="http://yoursite.com', 'src="https://yoursite.com')
WHERE post_content LIKE '%src="http://yoursite.com%';
##-- Update SRC USING www with single quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, "src='http://www.yoursite.com", "src='https://yoursite.com")
WHERE post_content LIKE "%src='http://www.yoursite.com%";
##-- Update SRC WITHOUT www with single quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, "src='http://yoursite.com", "src='https://yoursite.com")
WHERE post_content LIKE "%src='http://yoursite.com%";
##-- Update HREF USING www with double quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, 'href="http://www.yoursite.com', 'href="https://yoursite.com')
WHERE post_content LIKE '%href="http://www.yoursite.com%';
##-- Update HREF WITHOUT www with double quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, 'href="http://yoursite.com', 'href="https://yoursite.com')
WHERE post_content LIKE '%href="http://yoursite.com%';
##-- Update HREF USING www with single quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, "href='http://www.yoursite.com", "href='https://yoursite.com")
WHERE post_content LIKE "%href='http://www.yoursite.com%";
##-- Update HREF WITHOUT www with single quotes
UPDATE `wp_posts` SET post_content = REPLACE(post_content, "href='http://yoursite.com", "href='https://yoursite.com")
WHERE post_content LIKE "%href='http://yoursite.com%";
##-- Update any “pinged” links USING www
UPDATE `wp_posts` SET pinged = REPLACE(pinged, 'http://www.yoursite.com', 'https://yoursite.com')
WHERE pinged LIKE '%http://www.yoursite.com%';
##-- Update any “pinged” links WITHOUT www
UPDATE `wp_posts` SET pinged = REPLACE(pinged, 'http://yoursite.com', 'https://yoursite.com')
WHERE pinged LIKE '%http://yoursite.com%';
##-- Update any comment links USING www
UPDATE `wp_comments` SET comment_content = REPLACE(comment_content, 'http://www.yoursite.com', 'https://yoursite.com')
WHERE comment_content LIKE '%http://www.yoursite.com%';
##-- Update any comment links WITHOUT www
UPDATE `wp_comments` SET comment_content = REPLACE(comment_content, 'http://yoursite.com', 'https://yoursite.com')
WHERE comment_content LIKE '%http://yoursite.com%';
##-- Update any POST META links USING www
UPDATE `wp_postmeta` SET `meta_value` = REPLACE(meta_value, 'http://www.yoursite.com', 'https://yoursite.com')
WHERE meta_value LIKE '%http://www.yoursite.com%';
##-- Update any POST META links WITHOUT www
UPDATE `wp_postmeta` SET `meta_value` = REPLACE(meta_value, 'http://yoursite.com', 'https://yoursite.com')
WHERE meta_value LIKE '%http://yoursite.com%';
##-- Update Iframes
UPDATE `wp_postmeta`
SET meta_value=(REPLACE (meta_value, 'iframe src="http://','iframe src="//'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment