If there is a need to move WordPress installation to another domain or move it from production to localhost, launching of copied files and database will not work. Posts stored in database and some wp options contains information about domain name, so dynamic links will redirect to unknown pages. To fix this, after copying database and necessary files to new domain, just simply replace mentioned entries directly in MySql using sql commands.
For wp_options table in Your WordPress:
1 2 3 4 |
UPDATE wp_options SET option_value = replace(option_value, 'http://www.source-domain.com', 'http://www.target-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl'; |
For wp_posts table in Your WordPress:
1 2 |
UPDATE wp_posts SET guid = replace(guid, 'http://www.source-domain.com','http://www.target-domain.com'); |
1 2 |
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.source-domain.com', 'http://www.target-domain.com'); |
Those changes should properly set new domain and make it work.
This is not the only way to move WordPress – codex.wordpress.org contains detailed information about moving to another location.
Also there is a very usefull tool to search and replace domain entries in database without using any sql command. This tool is available here: Search And Replace Tool. It’s a single script file which can be use not only with WordPress.