Created
April 2, 2015 15:53
-
-
Save andrewspear/16c3d104b2123d42c8e4 to your computer and use it in GitHub Desktop.
If you are updating the domain of your website but it's running Wordpress, run the code below to update all the old domain references in the database with new domain references.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE `wp_posts` SET `guid` = replace(guid, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_posts` SET `post_content` = replace(post_content, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_options` SET `option_value` = replace(option_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_comments` SET `comment_content` = replace(comment_content, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_comments` SET `comment_author_url` = replace(comment_author_url, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_commentmeta` SET `meta_value` = replace(meta_value, 'http://old.domain.com', 'https://new.domain.com'); | |
UPDATE `wp_users` SET `user_url` = replace(user_url, 'http://old.domain.com', 'https://new.domain.com'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on Wordpress 4.1.1