Posted on Jul 3, 2011 in WordPress | 0 comments
When you move your WordPress site, letting the site know about its new URL can be a hassle, but can lead to many types of errors if you are not careful: the site may not load at all, only the home page may load, images may not load properly, internal links may be broken, and so on. Here is a checklist for the next time you have to do this.
There are two main ways to do this; one requires access to run SQL queries (usually by using the PHPMyAdmin tool in your web host’s dashboard, which is typically CPanel), and the other requires editing files through FTP and using a plugin.
Copy the following into the “SQL” tab of PHPMyAdmin. Make sure to change the URLs in each query to reflect the correct old and new URL. I prefer to first copy it into Notepad, then use the find and replace tool to accomplish this.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://www.oldsiteurl.com','http://www.newsiteurl.com');
These queries come from the excellent article, 13 Useful WordPress SQL Queries You Wish You Knew Earlier. However, beware of the query in the article to change GUIDs in your database. The WordPress Codex explicitly warns to “never, ever” change GUIDs in the database.
Don’t forget to refresh your permalinks!
The Velvet Blues Update URLs plugin is a wonderful tool to update your site URL. However, you won’t be able to login to WordPress until two key URLs have been changed.
The WordPress Codex describes multiple ways to change your “site URL” and “home” values without direct SQL access. If you follow these methods, I find Filezilla to be quite useful, since you can right-click a file, choose to edit it, make your changes, save it and have it automatically go back to the server. This saves you several steps.
After you do that, you should be able to access your site and install the Velvet Blues Update URLs plugin. Once the plugin is installed, to go Settings > Update URLs. The plugin has a simple interface: just select that you want to update permalinks, then specify the full old and new URLs (including the http://) and then away you go!
0 Comments
Trackbacks/Pingbacks