问题
I recently moved a friends blog onto his new web hosts but unfortunately the images are not working.
This is due to the old host having the following path for images:
http://www.example.com/blog/wp-content/uploads/2009/07/imagename.jpg
The new host uses a different layout and has this path for the file:
http://www.example.com/wp-content/uploads/2009/07/imagename.jpg
'Blog' has been removed.
Does anyone know the easiest way to fix this issue?
回答1:
I've found this tutorial on Exporting and Importing Wordpress very helpful in such situations.
回答2:
Use this query on your database:
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com/blog','http://www.new-domain.com');
回答3:
Search RegEx is a good plugin to be able to search and replace with Grep through all posts and pages. Also look in template files for hardcoded links in the form of <>php bloginfo(); ?>
for the unneeded /blog/ in the path.
回答4:
Search replace is a good plugin as well as Search RegEx. Especially if your data to replace is widespread throughout your site. http://wordpress.org/extend/plugins/search-and-replace/
来源:https://stackoverflow.com/questions/2468141/changing-paths-to-images-in-wordpress