I'm helping a friend fix some problems with the migration of their word press site and I don't use WP much, but I know PHP/SQL/CSS/HTML/etc. They installed and built the site on "JunkDomain.com" and moved it to a different server "test.domain.com" where "domain.com" will be the final live version.
The junkdomain.com version that was moved over has a lot of absolute url references using JunkDomain.com. When he moved it over he linked the JunkDomain.com file system up as a mirror and didn't notice that everything on test.domain.com was really pulling a lot of stuff from JunkDomain.com.
I've found WP using the absolute urls to junkdomain.com in:
- html page links
- image src's
Once junkdomain.com goes away, all his stuff is going to break. I could just search & replace in the SQL, widgets, etc. But I thought I'd ask here since I also plan to go from test.domain.com to domain.com.
What's the best way to remap these to the test.domain.com? and What's the best way to manage rolling out from test.domain.com to domain.com?
Whats the best WP practice to use absolute or relative URLs for widgets/images/etc?
The chosen answer worked -- See option #2 from this document http://codex.wordpress.org/Moving_WordPress
If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:
- Only perform a search and replace on the wp_posts table.
- Use the Search and Replace for WordPress Databases Script to safely change all instances. (If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below)
- Optionally, you can also use an online tool (in case you don't want to bother with uploading scripts to your server) Online WordPress Serialized PHP Search and Replace which allows for replacing an old domain or URL with a new one while fixing the serialized data at the same time.